且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将文件从可变文件夹移动到另一个

更新时间:2022-12-03 21:45:36

第一个问题
First problem
string path = Path.Combine(textBoxFolderToWatch.Text, FileName);
string path2 = Path.Combine(textBoxtogo.Text, FileName);


非常简单,即使您不阅读文档

第二个问题


Very simple, even if you don''t read the documentation

Second problem

private string GetPath(string path)
{
  int version = 1;
  string fileName = Path.GetFileNameWithoutExtension(path);
  string folder = Path.GetDirectoryName(path);
  string extentions = Path.GetExtention(path);2
  while( File.Exists(path) )
  {
     path = Path.Combine(folder, fileName + version++);
     path = Path.Combine(path, extention);
  }

  return path;
}