本文整理汇总了C#中System.IO.DirectoryInfo.CreateSubdirectory方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.DirectoryInfo.CreateSubdirectory方法的具体用法?C# System.IO.DirectoryInfo.CreateSubdirectory怎么用?C# System.IO.DirectoryInfo.CreateSubdirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.DirectoryInfo
的用法示例。
在下文中一共展示了System.IO.DirectoryInfo.CreateSubdirectory方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DirectoryCheck
private void DirectoryCheck(String userName)
{
var receiptImageDir = new System.IO.DirectoryInfo(Server.MapPath("~/IMG/"));
if (!receiptImageDir.Exists)
{
var createReceiptImageDir = new System.IO.DirectoryInfo(Server.MapPath("~"));
createReceiptImageDir.CreateSubdirectory("IMG/");
}
receiptImageDir = new System.IO.DirectoryInfo(Server.MapPath("~/IMG/receiptImage/"));
if (!receiptImageDir.Exists)
{
var createReceiptImageDir = new System.IO.DirectoryInfo(Server.MapPath("~/IMG"));
createReceiptImageDir.CreateSubdirectory("receiptImage/");
}
receiptImageDir = new System.IO.DirectoryInfo(Server.MapPath("~/IMG/receiptImage/"
+ userName + "/"));
if (!receiptImageDir.Exists)
{
var createReceiptImageDir = new System.IO.DirectoryInfo(Server.MapPath("~/IMG/receiptImage/"));
createReceiptImageDir.CreateSubdirectory(userName + "/");
}
}
示例2: CreateJob
/// <summary>
/// Creates the job.
/// </summary>
/// <param name="seq">The seq.</param>
/// <param name="wgt">The WGT.</param>
/// <param name="name">The name.</param>
/// <param name="confFile">The conf file.</param>
public static void CreateJob(
string family, //Resources.CompositeResource family,
Resources.SeqFileResource seq,
Resources.WgtFileResource wgt,
string name,
string confFile)
{
/// create a new folder for the job
System.IO.DirectoryInfo jobsFolder =
new System.IO.DirectoryInfo(Program.CurrentOptions.JobFolder);
System.IO.DirectoryInfo jobFolder =
jobsFolder.CreateSubdirectory(family.Replace('.', '\\'));
System.IO.DirectoryInfo jobDataFolder =
jobFolder.CreateSubdirectory ("data");
/// now copy the conf, seq, and wgt files to the directory
System.IO.File.Copy (
seq.Filename,
System.IO.Path.Combine (jobDataFolder.FullName, "sequence.fasta")
);
System.IO.File.Copy(
wgt.Filename,
System.IO.Path.Combine(jobDataFolder.FullName, "sequence.wgt")
);
System.IO.File.Copy(
confFile,
System.IO.Path.Combine(jobDataFolder.FullName, "seed.conf")
);
System.IO.File.Copy (
System.IO.Path.Combine (Program.CurrentOptions.DataFolder, "RunMe.bat"),
System.IO.Path.Combine(jobFolder.FullName, "RunMe.bat")
);
System.Environment.CurrentDirectory = jobFolder.FullName;
System.Diagnostics.Process process =
System.Diagnostics.Process.Start(System.IO.Path.Combine(jobFolder.FullName, "RunMe.bat"));
process.WaitForExit();
int exitCode = process.ExitCode;
}
示例3: Print
public void Print(IList<FilmBox> filmBoxList)
{
try
{
Status = PrintJobStatus.Pending;
OnStatusUpdate("Preparing films for printing");
var printJobDir = new System.IO.DirectoryInfo(FullPrintJobFolder);
if (!printJobDir.Exists)
{
printJobDir.Create();
}
DicomFile file;
int filmsCount = FilmBoxFolderList.Count;
for (int i = 0; i < filmBoxList.Count; i++)
{
var filmBox = filmBoxList[i];
var filmBoxDir = printJobDir.CreateSubdirectory(string.Format("F{0:000000}", i + 1 + filmsCount));
file = new DicomFile(filmBox.FilmSession);
file.Save(string.Format(@"{0}\FilmSession.dcm", filmBoxDir.FullName));
FilmBoxFolderList.Add(filmBoxDir.Name);
filmBox.Save(filmBoxDir.FullName);
}
FilmSessionLabel = filmBoxList.First().FilmSession.FilmSessionLabel;
var thread = new Thread(new ThreadStart(DoPrint));
thread.Name = string.Format("PrintJob {0}", SOPInstanceUID.UID);
thread.IsBackground = true;
thread.Start();
}
catch (Exception ex)
{
Error = ex;
Status = PrintJobStatus.Failure;
OnStatusUpdate("Print failed");
DeletePrintFolder();
}
}
示例4: ClientFoldersInit
/*Custom*/
private void ClientFoldersInit(string userFolder, int siteId)
{
string CurrentPath = System.IO.Path.Combine(System.Web.HttpContext.Current.Server.MapPath(userFolder), siteId.ToString());
System.IO.DirectoryInfo EditDirectory = new System.IO.DirectoryInfo(CurrentPath);
// Check if a folder exists and create if it does not
if (!EditDirectory.Exists)
{
EditDirectory.Create();
EditDirectory.CreateSubdirectory("file");
EditDirectory.CreateSubdirectory("image");
EditDirectory.CreateSubdirectory("flash");
EditDirectory.CreateSubdirectory("media");
EditDirectory.CreateSubdirectory("downloads");
}
}
示例5: SubdirectoriedAreWachedIfIncludeSubdirIsTrue
public void SubdirectoriedAreWachedIfIncludeSubdirIsTrue()
{
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(".");
System.IO.DirectoryInfo subdir = dir.CreateSubdirectory(Guid.NewGuid().ToString());
string fileName = System.IO.Path.Combine(subdir.FullName, Guid.NewGuid().ToString());
string newFileName = System.IO.Path.Combine(subdir.FullName, Guid.NewGuid().ToString());
try
{
AutoResetEvent raised = new AutoResetEvent(false);
FileSystemWatcher tested = new FileSystemWatcher(dir.FullName);
tested.IncludeSubdirectories = true;
tested.EnableRaisingEvents = true;
int CreateRaised = 0;
int ChangedRaised = 0;
int DeletedRaised = 0;
int RenamedRaised = 0;
tested.Created += (s, e) => CreateRaised++;
tested.Changed += (s, e) => ChangedRaised++;
tested.Deleted += (s, e) => DeletedRaised++;
tested.Renamed += (s, e) => RenamedRaised++;
using (System.IO.FileStream file = System.IO.File.Create(fileName))
{
byte[] data = Encoding.UTF8.GetBytes("somedata");
file.Write(data, 0, data.Length);
file.Flush();
file.Close();
};
Thread.Sleep(200);
using (System.IO.FileStream file = System.IO.File.OpenWrite(fileName))
{
byte[] data = Encoding.UTF8.GetBytes("somedata");
file.Write(data, 0, data.Length);
file.Flush();
file.Close();
};
Thread.Sleep(200);
System.IO.File.Move(fileName, newFileName);
Thread.Sleep(200);
System.IO.File.Delete(newFileName);
Thread.Sleep(200);
Assert.AreEqual(1, CreateRaised);
Assert.IsTrue(ChangedRaised > 0);
Assert.AreEqual(1, DeletedRaised);
Assert.AreEqual(1, RenamedRaised);
}
finally
{
subdir.Delete(true);
}
}
示例6: Main
//.........这里部分代码省略.........
outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
outFile.WriteLine ("Time: " + GetTime (now));
outFile.WriteLine ("Retv: " + "");
outFile.WriteLine ("Errc: " + "");
outFile.WriteLine ("Exce: " + GetException (exc));
}
try {
exc = null;
now = System.DateTime.Now;
System.IO.Directory.Delete (tempPath + "\\TestDir2");
} catch (Exception e) {
exc = e;
} finally {
outFile.WriteLine ("Name: " + tempPath + "\\TestDir2");
outFile.WriteLine ("Func: " + "System.IO.Directory.Delete(String)");
outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
outFile.WriteLine ("Time: " + GetTime (now));
outFile.WriteLine ("Retv: " + "");
outFile.WriteLine ("Errc: " + "");
outFile.WriteLine ("Exce: " + GetException (exc));
}
} catch (Exception) {
}
try {
di = null;
di = new System.IO.DirectoryInfo (tempPath);
System.IO.DirectoryInfo di2 = null;
try {
try {
exc = null;
di2 = null;
now = System.DateTime.Now;
di2 = di.CreateSubdirectory (tempPath + "\\TestDir3");
di = di2;
} catch (Exception e) {
exc = e;
} finally {
outFile.WriteLine ("Name: " + tempPath + "\\TestDir3");
outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.CreateSubdirectory(String)");
outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
outFile.WriteLine ("Time: " + GetTime (now));
outFile.WriteLine ("Retv: " + toString (di2));
outFile.WriteLine ("Errc: " + "");
outFile.WriteLine ("Exce: " + GetException (exc));
}
try {
exc = null;
fiL = null;
now = System.DateTime.Now;
fiL = di.GetFiles ();
} catch (Exception e) {
exc = e;
} finally {
outFile.WriteLine ("Name: " + tempPath + "\\TestDir3");
outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.GetFiles()");
outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
outFile.WriteLine ("Time: " + GetTime (now));
outFile.WriteLine ("Retv: " + toString (fiL));
outFile.WriteLine ("Errc: " + "");
outFile.WriteLine ("Exce: " + GetException (exc));
}
try {
exc = null;
diL = null;
now = System.DateTime.Now;