打开文件夹,供操作者选择文件:
OpenFileDialog dialog = new OpenFileDialog();
dialog.ShowDialog();
获得所选文件的文件名:
string fileName=dialoa.FileName;
获取所选文件的文件夹目录:
FileInfo fi = new FileInfo(t);
string path = fileName.Substring(0, t.Length - fi.Name.Length);
将文件移动到别的目录:
string movePath="......";
fi.move(movePath);
/******************************************************
FileInfo类操作文件还有许多的情况不一一列举
******************************************************/
StreamReader sr = new StreamReader(filePath);
sr.ReadLine();
FileStream fStream = new FileStream(FilePath, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(fStream);
sw.WriteLine();
sw.Close();
string path="......."
FileStream fStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
原文:https://www.cnblogs.com/YichengLiu/p/11050741.html