D
Dyl
Hi all,
I am having a problem with a command prompt process. It runs the cmd
prompt sucessfully, and changes the directory succesfully, but I can't
get the StartInfo.Arguments to work properly. My code is below, the
first stuff finds the most recently modified folder.
DirectoryInfo Direc = new DirectoryInfo(@"U:\MyFld\October");
DirectoryInfo[] FoldersArr = Direc.GetDirectories();
DateTime MostRecent = FoldersArr[0].LastWriteTime;
DirectoryInfo MostRecentDir = FoldersArr[0];
for (int i = 1; i < FoldersArr.Length; i++)
{
if (MostRecent.CompareTo(FoldersArr.LastWriteTime) < 0)
{
MostRecent = FoldersArr.LastWriteTime;
MostRecentDir = FoldersArr;
}
}
-------------------------Process-----------------------------------
Process proc = new Process();
proc.StartInfo.FileName = "cmd";
proc.StartInfo.WorkingDirectory = @Direc.FullName;
proc.StartInfo.Arguments = "compact /u /s:" +
MostRecentDir.Name;
proc.StartInfo.UseShellExecute = false;
proc.Start();
I am having a problem with a command prompt process. It runs the cmd
prompt sucessfully, and changes the directory succesfully, but I can't
get the StartInfo.Arguments to work properly. My code is below, the
first stuff finds the most recently modified folder.
DirectoryInfo Direc = new DirectoryInfo(@"U:\MyFld\October");
DirectoryInfo[] FoldersArr = Direc.GetDirectories();
DateTime MostRecent = FoldersArr[0].LastWriteTime;
DirectoryInfo MostRecentDir = FoldersArr[0];
for (int i = 1; i < FoldersArr.Length; i++)
{
if (MostRecent.CompareTo(FoldersArr.LastWriteTime) < 0)
{
MostRecent = FoldersArr.LastWriteTime;
MostRecentDir = FoldersArr;
}
}
-------------------------Process-----------------------------------
Process proc = new Process();
proc.StartInfo.FileName = "cmd";
proc.StartInfo.WorkingDirectory = @Direc.FullName;
proc.StartInfo.Arguments = "compact /u /s:" +
MostRecentDir.Name;
proc.StartInfo.UseShellExecute = false;
proc.Start();