Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从其他文件夹子目录创建子目录_C# - Fatal编程技术网

C# 从其他文件夹子目录创建子目录

C# 从其他文件夹子目录创建子目录,c#,C#,嗨 我希望上面的内容是正确的,我正在使用c#创建我的第一个项目,但是我有一些问题,基本上我想要实现的是获得文件所在的子文件夹,然后在新文件夹中创建与该文件相同的子目录 e、 g: 文件夹1:c:\test\test\test.txt(路径由用户选择文件夹生成) 文件夹2:c:\test1\test\test.txt(同上) 文件夹3:c:\test2(同上) 现在我想在文件夹3中创建一个名为test的子目录,并在其中创建test.txt文件 我尝试使用Get.Directories,但是我得到了

我希望上面的内容是正确的,我正在使用c#创建我的第一个项目,但是我有一些问题,基本上我想要实现的是获得文件所在的子文件夹,然后在新文件夹中创建与该文件相同的子目录

e、 g:

文件夹1:c:\test\test\test.txt(路径由用户选择文件夹生成)

文件夹2:c:\test1\test\test.txt(同上)

文件夹3:c:\test2(同上)

现在我想在文件夹3中创建一个名为test的子目录,并在其中创建test.txt文件

我尝试使用Get.Directories,但是我得到了一个完整路径(c:\test2\c:\test1\text\test.txt),因此只能创建\test\test.txt

其中有很多文件和子目录以及子目录

Bsdiff,比较两个文件,然后在它们之间创建一个修补程序文件,这样我可以让它为两个文件夹中存在的项目创建修补程序文件,但我也想尝试将它们放入以前所在的同名文件夹中

如果代码是草率的:(很抱歉,对整个事情还是相当陌生的


谢谢

string newPath=oldPath.Replace(oldRootDirectory,newRootDirectory);
string[] oldFilesArray = Directory.GetFiles(oldFolderDialog.SelectedPath, "*", SearchOption.AllDirectories);            
string[] newFilesArray = Directory.GetFiles(newFolderDialog.SelectedPath, "*", SearchOption.AllDirectories);         
        foreach (string oldFile in oldFilesArray)
        {
            string oldFileNames = Path.GetFileName(oldFile);
            foreach(string newFile in newFilesArray)
            {
                string newFileNames = Path.GetFileName(newFile);                    
                if (newFileNames == oldFileNames)
                {
                    string extension = ".patch";
                    Environment.CurrentDirectory = Application.StartupPath; //The Application was crashing on Windows XP without this line.
                    ProcessStartInfo bsdiff = new ProcessStartInfo();
                    bsdiff.FileName = "bsdiff.exe";
                    string bspatchArguments = "\"" + Path.GetFullPath(oldFile) + "\"" + " "
                    + "\"" + Path.GetFullPath(newFile) + "\"" + " "
                    + "\"" + updateFolderPathLabel.Text + "\\" + Path.GetFileName(newFileNames) + extension + "\"";                        
                    Process.Start("bsdiff", bspatchArguments);                       
                }                   
            }
        }