本文整理汇总了C#中System.IO.DirectoryInfo.Create方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.DirectoryInfo.Create方法的具体用法?C# System.IO.DirectoryInfo.Create怎么用?C# System.IO.DirectoryInfo.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.DirectoryInfo
的用法示例。
在下文中一共展示了System.IO.DirectoryInfo.Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SettingManager
public SettingManager()
{
_cookieFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
_imageHashSerializer = new System.Xml.Serialization.XmlSerializer(typeof(HashSet<string>));
//設定ファイル読み込み
EmailAddress = GPlusImageDownloader.Properties.Settings.Default.EmailAddress;
Password = GPlusImageDownloader.Properties.Settings.Default.Password;
ImageSaveDirectory = new System.IO.DirectoryInfo(
string.IsNullOrEmpty(GPlusImageDownloader.Properties.Settings.Default.ImageSaveDirectory)
? Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\testFolder"
: GPlusImageDownloader.Properties.Settings.Default.ImageSaveDirectory);
Cookies = DeserializeCookie();
ImageHashList = DeserializeHashes();
if (!ImageSaveDirectory.Exists)
try
{
ImageSaveDirectory.Create();
ImageSaveDirectory.Refresh();
}
catch (System.IO.IOException)
{ IsErrorNotFoundImageSaveDirectory = !ImageSaveDirectory.Exists; }
else
IsErrorNotFoundImageSaveDirectory = false;
}
示例2: JobContainerViewModel
public JobContainerViewModel(ImageDownloaderContainer downloader)
{
ThumbDir = new System.IO.DirectoryInfo(string.Format("{0}\\{1}", System.IO.Path.GetTempPath(), System.IO.Path.GetRandomFileName()));
ThumbDir.Create();
_downloader = downloader;
_downloader.AddedDownloadingImage += _downloader_DownloadingImageEvent;
}
示例3: CreateTargetLocation
public static string CreateTargetLocation(string downloadToPath)
{
string filePath = downloadToPath;
System.IO.DirectoryInfo newFolder = new System.IO.DirectoryInfo(filePath);
if (!newFolder.Exists)
newFolder.Create();
return filePath;
}
示例4: ApiWrapperWithLogger
static ApiWrapperWithLogger()
{
exeDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
logDir = new System.IO.DirectoryInfo(exeDir + "\\NetworkLogs");
if (logDir.Exists == false)
logDir.Create();
else
foreach (var item in logDir.EnumerateFiles())
item.Delete();
}
示例5: HandlerData
private string HandlerData(HttpContext context)
{
StringBuilder sbResult = new StringBuilder();
try
{
HttpPostedFile file = context.Request.Files.Count > 0 ? context.Request.Files[0] : null;
if (file == null)
{
sbResult.Append("{sucess:false,msg:'上传文件为空!'}");
return sbResult.ToString();
}
string fileExtention = CY.Utility.Common.FileUtility.GetFileExtension(file.FileName);
string fileName = CY.Utility.Common.FileUtility.GetFileName(file.FileName);
if (fileExtention != ".doc" &&
fileExtention != ".docx" &&
fileExtention != ".pdf" &&
fileExtention != ".txt" &&
fileExtention != ".text" &&
fileExtention != "html" &&
fileExtention != ".htm")
{
sbResult.Append("{result:false,msg:'上传文件格式不正确,只允许上传:doc(x),pdf,t(e)xt,htm(l)等格式的文档!'}");
return sbResult.ToString();
}
if (file.ContentLength > 2000000)
{
sbResult.Append("{result:false,msg:'文件太大,上传文件的大小不能超过2Mb'}");
return sbResult.ToString();
}
string appPath = CY.Utility.Common.RequestUtility.CurPhysicalApplicationPath;
string dirPath = appPath + "\\Content\\Instrument\\File\\";
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(dirPath);
if (!di.Exists)
{
di.Create();
}
string filesaveName = fileName + DateTime.Now.ToString("yyyyMMddmmhhss") + DateTime.Now.Millisecond.ToString();
file.SaveAs(dirPath + filesaveName + fileExtention);
sbResult.Append("{success:true");
sbResult.Append(string.Format(",filePath:'{0}'", "../../../Content/Instrument/File/" + filesaveName + fileExtention));
sbResult.Append(string.Format(",fileName:'{0}'", fileName + fileExtention));
sbResult.Append("}");
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
return sbResult.ToString();
}
示例6: DownloadOnly
public static void DownloadOnly(string UrlFile, string subFolder, string NamaFile)
{
// Create a new WebClient instance.
using (WebClient myWebClient = new WebClient())
{
string AudioFile = Hadith.WPF.Tools.Logs.getPath() + "\\audio\\" + subFolder;
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(AudioFile);
if (!dir.Exists) dir.Create();
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFileAsync(new Uri(UrlFile, UriKind.RelativeOrAbsolute), AudioFile + "\\" + NamaFile);
}
}
示例7: Application_Start
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new Engine());
System.IO.DirectoryInfo di_ImageUpload = new System.IO.DirectoryInfo(Server.MapPath("~/") + "ImageUpload/");
di_ImageUpload.Create();
System.IO.DirectoryInfo di_HeadImg = new System.IO.DirectoryInfo(Server.MapPath("~/") + "HeadImg/");
di_HeadImg.Create();
System.IO.DirectoryInfo di_Attribute = new System.IO.DirectoryInfo(Server.MapPath("~/") + "Attribute/");
di_Attribute.Create();
Config.ArticleDataPath = Server.MapPath("~/") + "Article.db";
Qing.QLog.Init();
Qing.QLog.StartWS(Config.LogPort);
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
示例8: XMLResponse
public static void XMLResponse(Process[] toWrite, Type type)
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Async = true;
settings.CheckCharacters = false;
string path = @"D:/Alt/Cat/xml";
System.IO.DirectoryInfo dr= new System.IO.DirectoryInfo(path.Remove(path.LastIndexOf('/')));
if (!dr.Exists)
dr.Create();
XmlWriter xml = XmlWriter.Create(path, settings);
xml.WriteStartDocument();
foreach (var elem in toWrite)
{
xml.WriteValue(elem.
}
xml.WriteEndDocument();
xml.Close();
}
示例9: rasterUtil
public rasterUtil()
{
string mainPath = System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\RmrsRasterUtilityHelp";
string globFuncDir = mainPath + "\\func";
string globMosaicDir = mainPath + "\\mosaic";
string globConvDir = mainPath + "\\conv";
System.IO.DirectoryInfo DInfo = new System.IO.DirectoryInfo(globFuncDir);
if (!DInfo.Exists)
{
DInfo.Create();
}
if (!System.IO.Directory.Exists(globMosaicDir)) System.IO.Directory.CreateDirectory(globMosaicDir);
if (!System.IO.Directory.Exists(globConvDir)) System.IO.Directory.CreateDirectory(globConvDir);
mosaicDir = globMosaicDir + "\\" + newGuid;
funcDir = globFuncDir + "\\" + newGuid;
convDir = globConvDir + "\\" + newGuid;
fp = newGuid.Substring(1, 3);
System.IO.Directory.CreateDirectory(funcDir);
System.IO.Directory.CreateDirectory(convDir);
System.IO.Directory.CreateDirectory(mosaicDir);
}
示例10: Put
public void Put(System.IO.Stream stream, string fileName)
{
var prefix = fileName.Substring(0, 2);
var folder = new System.IO.DirectoryInfo(System.IO.Path.Combine(this.RootPath, prefix));
if (!folder.Exists)
folder.Create();
var buffer = new byte[4096];
int count = 0;
using (var outFile = System.IO.File.Open(System.IO.Path.Combine(this.RootPath, prefix, fileName), System.IO.FileMode.CreateNew))
{
while (true)
{
count = stream.Read(buffer, 0, buffer.Length);
if (count <= 0)
break;
outFile.Write(buffer, 0, count);
}
}
}
示例11: Run
public static void Run(ControllerConfiguration context, Guid versionKey)
{
var versionsController = new Versions(context);
System.IO.DirectoryInfo pushFolder = new System.IO.DirectoryInfo(Program.STR_PUSH_FOLDER);
System.IO.DirectoryInfo pullFolder = new System.IO.DirectoryInfo(Program.STR_PULL_FOLDER);
versionsController.PushVersion(pushFolder, versionKey);
if (!pullFolder.Exists)
{
pullFolder.Create();
pullFolder.Refresh();
}
versionsController.PullVersion(versionKey, pullFolder);
pullFolder.Refresh();
var pulledFiles = pullFolder.GetFiles("*", System.IO.SearchOption.AllDirectories);
Debug.Assert(pulledFiles.Length == 2);
Debug.Assert(pulledFiles.Any(f => f.FullName == String.Format(@"{0}\Subfolder\AnImage.bmp", Program.STR_PULL_FOLDER)));
Debug.Assert(pulledFiles.Any(f => f.FullName == String.Format(@"{0}\README.txt", Program.STR_PULL_FOLDER)));
}
示例12: ProcessRequest
public void ProcessRequest(System.Web.HttpContext context)
{
if (!string.IsNullOrEmpty(context.Request.Headers["X-File-Name"]))
{
string path = context.Server.MapPath("~/Uploads");
string file = System.IO.Path.Combine(path, context.Request.Headers["X-File-Name"]);
// throw new Exception(System.Environment.UserName);
int cnt = context.Request.Files.Count;
System.Console.WriteLine (cnt);
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path);
if (!di.Exists) di.Create();
using (System.IO.FileStream fileStream = new System.IO.FileStream(file, System.IO.FileMode.OpenOrCreate))
{
// context.Request.InputStream.CopyTo(fileStream);
CopyStream(context.Request.InputStream, fileStream);
fileStream.Close();
} // End Using fileStream
} // End if (!string.IsNullOrEmpty(context.Request.Headers["X-File-Name"]))
}
示例13: DownloadAndPlay
public static string DownloadAndPlay(string UrlFile, string subFolder, string NamaFile)
{
string TargetFileName = string.Empty;
try
{
// Create a new WebClient instance.
using (WebClient myWebClient = new WebClient())
{
string AudioFile = Hadith.WPF.Tools.Logs.getPath() + "\\audio\\" + subFolder;
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(AudioFile);
if (!dir.Exists) dir.Create();
// Download the Web resource and save it into the current filesystem folder.
TargetFileName = AudioFile + "\\" + NamaFile;
if (System.IO.File.Exists(TargetFileName)) return TargetFileName;
myWebClient.DownloadFile(new Uri(UrlFile, UriKind.RelativeOrAbsolute), TargetFileName);
}
return TargetFileName;
}
catch
{
return null;
}
}
示例14: LoadCachedApkIconsToImageList
private void LoadCachedApkIconsToImageList(ImageList il)
{
AlphaImageList.AddFromImage((Image)DroidExplorer.Resources.Images.folder_Closed_16xLG, SmallImageList);
AlphaImageList.AddFromImage((Image)DroidExplorer.Resources.Images.folder_Closed_16xLG_Link, SmallImageList);
AlphaImageList.AddFromImage((Image)DroidExplorer.Resources.Images.text_document_16, SmallImageList);
AlphaImageList.AddFromImage((Image)DroidExplorer.Resources.Images.application_16xLG, SmallImageList);
AlphaImageList.AddFromImage((Image)DroidExplorer.Resources.Images.text_document_16_link, SmallImageList);
AlphaImageList.AddFromImage((Image)DroidExplorer.Resources.Images.application_16xLG_Link, SmallImageList);
AlphaImageList.AddFromImage((Image)DroidExplorer.Resources.Images.folder_Closed_32xLG, LargeImageList);
AlphaImageList.AddFromImage((Image)DroidExplorer.Resources.Images.folder_Closed_32xLG_Link, LargeImageList);
AlphaImageList.AddFromImage((Image)DroidExplorer.Resources.Images.text_document_32, LargeImageList);
AlphaImageList.AddFromImage((Image)DroidExplorer.Resources.Images.application_32xLG, LargeImageList);
AlphaImageList.AddFromImage((Image)DroidExplorer.Resources.Images.text_document_32_Link, LargeImageList);
AlphaImageList.AddFromImage((Image)DroidExplorer.Resources.Images.application_32xLG_Link, LargeImageList);
AddFileTypeImage(".txt", (Image)DroidExplorer.Resources.Images.text_document_16, (Image)DroidExplorer.Resources.Images.text_document_32);
AddFileTypeImage(".prop", (Image)DroidExplorer.Resources.Images.text_document_16, (Image)DroidExplorer.Resources.Images.text_document_32);
AddFileTypeImage(".log", (Image)DroidExplorer.Resources.Images.PickAxe_16xLG, (Image)DroidExplorer.Resources.Images.PickAxe_32xLG);
AddFileTypeImage(".sh", (Image)DroidExplorer.Resources.Images.shellscript_16xLG, (Image)DroidExplorer.Resources.Images.shellscript_32xLG);
AddFileTypeImage(".csv", (Image)DroidExplorer.Resources.Images.text_document_16, (Image)DroidExplorer.Resources.Images.text_document_32);
AddFileTypeImage(".so", (Image)DroidExplorer.Resources.Images.library_16xLG, (Image)DroidExplorer.Resources.Images.library_32xLG);
AddFileTypeImage(".dex", (Image)DroidExplorer.Resources.Images.package, (Image)DroidExplorer.Resources.Images.package32);
AddFileTypeImage(".odex", (Image)DroidExplorer.Resources.Images.package, (Image)DroidExplorer.Resources.Images.package32);
AddFileTypeImage(".sqlite", (Image)DroidExplorer.Resources.Images.database_16xLG, (Image)DroidExplorer.Resources.Images.database_32xLG);
AddFileTypeImage(".db", (Image)DroidExplorer.Resources.Images.database_16xLG, (Image)DroidExplorer.Resources.Images.database_32xLG);
AddFileTypeImage(".database", (Image)DroidExplorer.Resources.Images.database_16xLG, (Image)DroidExplorer.Resources.Images.database_32xLG);
// apk cache icons
var path = System.IO.Path.Combine(CommandRunner.Settings.UserDataDirectory, Cache.APK_IMAGE_CACHE);
System.IO.DirectoryInfo apkCache = new System.IO.DirectoryInfo(path);
if(!apkCache.Exists) {
apkCache.Create();
}
foreach(System.IO.FileInfo fi in apkCache.GetFiles("*.png")) {
Image image = Image.FromFile(fi.FullName);
AddFileTypeImage(System.IO.Path.GetFileNameWithoutExtension(fi.Name).ToLower(), image, image);
}
// file cache icons
path = System.IO.Path.Combine(CommandRunner.Settings.UserDataDirectory, Cache.ICON_IMAGE_CACHE);
System.IO.DirectoryInfo cache = new System.IO.DirectoryInfo(path);
if(!cache.Exists) {
cache.Create();
}
foreach(System.IO.FileInfo fi in cache.GetFiles("*.png").Union(cache.GetFiles("*.jpg"))) {
var image = Image.FromFile(fi.FullName);
AddFileTypeImage(System.IO.Path.GetFileNameWithoutExtension(fi.Name).ToLower(), image, image);
}
}
示例15: HandleConnection
static void HandleConnection(System.IO.DirectoryInfo info, TcpClient client)
{
Area ws = null;
ClientStateInfo clientInfo = new ClientStateInfo();
using (client)
using (SharedNetwork.SharedNetworkInfo sharedInfo = new SharedNetwork.SharedNetworkInfo())
{
try
{
var stream = client.GetStream();
Handshake hs = ProtoBuf.Serializer.DeserializeWithLengthPrefix<Handshake>(stream, ProtoBuf.PrefixStyle.Fixed32);
DomainInfo domainInfo = null;
lock (SyncObject)
{
if (hs.RequestedModule == null)
hs.RequestedModule = string.Empty;
if (!Domains.TryGetValue(hs.RequestedModule, out domainInfo))
{
domainInfo = Domains.Where(x => x.Key.Equals(hs.RequestedModule, StringComparison.OrdinalIgnoreCase)).Select(x => x.Value).FirstOrDefault();
}
if (domainInfo == null)
{
if (!Config.AllowVaultCreation || !Config.RequiresAuthentication || string.IsNullOrEmpty(hs.RequestedModule) || System.IO.Directory.Exists(System.IO.Path.Combine(info.FullName, hs.RequestedModule)))
{
Network.StartTransaction startSequence = Network.StartTransaction.CreateRejection();
Printer.PrintDiagnostics("Rejecting client due to invalid domain: \"{0}\".", hs.RequestedModule);
ProtoBuf.Serializer.SerializeWithLengthPrefix<Network.StartTransaction>(stream, startSequence, ProtoBuf.PrefixStyle.Fixed32);
return;
}
domainInfo = new DomainInfo()
{
Bare = true,
Directory = null
};
}
}
try
{
ws = Area.Load(domainInfo.Directory, true, true);
if (domainInfo.Bare)
throw new Exception("Domain is bare, but workspace could be loaded!");
}
catch
{
if (!domainInfo.Bare)
throw new Exception("Domain not bare, but couldn't load workspace!");
}
Printer.PrintDiagnostics("Received handshake - protocol: {0}", hs.VersionrProtocol);
SharedNetwork.Protocol? clientProtocol = hs.CheckProtocol();
bool valid = true;
if (clientProtocol == null)
valid = false;
else
{
valid = SharedNetwork.AllowedProtocols.Contains(clientProtocol.Value);
if (Config.RequiresAuthentication && !SharedNetwork.SupportsAuthentication(clientProtocol.Value))
valid = false;
}
if (valid)
{
sharedInfo.CommunicationProtocol = clientProtocol.Value;
Network.StartTransaction startSequence = null;
clientInfo.Access = Rights.Read | Rights.Write;
clientInfo.BareAccessRequired = domainInfo.Bare;
if (PrivateKey != null)
{
startSequence = Network.StartTransaction.Create(domainInfo.Bare ? string.Empty : ws.Domain.ToString(), PublicKey, clientProtocol.Value);
Printer.PrintDiagnostics("Sending RSA key...");
ProtoBuf.Serializer.SerializeWithLengthPrefix<Network.StartTransaction>(stream, startSequence, ProtoBuf.PrefixStyle.Fixed32);
if (!HandleAuthentication(clientInfo, client, sharedInfo))
throw new Exception("Authentication failed.");
StartClientTransaction clientKey = ProtoBuf.Serializer.DeserializeWithLengthPrefix<StartClientTransaction>(stream, ProtoBuf.PrefixStyle.Fixed32);
System.Security.Cryptography.RSAOAEPKeyExchangeDeformatter exch = new System.Security.Cryptography.RSAOAEPKeyExchangeDeformatter(PrivateKey);
byte[] aesKey = exch.DecryptKeyExchange(clientKey.Key);
byte[] aesIV = exch.DecryptKeyExchange(clientKey.IV);
Printer.PrintDiagnostics("Got client key: {0}", System.Convert.ToBase64String(aesKey));
var aesCSP = System.Security.Cryptography.AesManaged.Create();
sharedInfo.DecryptorFunction = () => { return aesCSP.CreateDecryptor(aesKey, aesIV); };
sharedInfo.EncryptorFunction = () => { return aesCSP.CreateEncryptor(aesKey, aesIV); };
}
else
{
startSequence = Network.StartTransaction.Create(domainInfo.Bare ? string.Empty : ws.Domain.ToString(), clientProtocol.Value);
ProtoBuf.Serializer.SerializeWithLengthPrefix<Network.StartTransaction>(stream, startSequence, ProtoBuf.PrefixStyle.Fixed32);
if (!HandleAuthentication(clientInfo, client, sharedInfo))
throw new Exception("Authentication failed.");
StartClientTransaction clientKey = ProtoBuf.Serializer.DeserializeWithLengthPrefix<StartClientTransaction>(stream, ProtoBuf.PrefixStyle.Fixed32);
}
sharedInfo.Stream = stream;
sharedInfo.Workspace = ws;
sharedInfo.ChecksumType = Config.ChecksumType;
clientInfo.SharedInfo = sharedInfo;
while (true)
{
NetCommand command = ProtoBuf.Serializer.DeserializeWithLengthPrefix<NetCommand>(stream, ProtoBuf.PrefixStyle.Fixed32);
if (command.Type == NetCommandType.Close)
//.........这里部分代码省略.........