C#里一些File操作
获取文件名称,去除扩展名
Path.GetFileNameWithoutExtension(productPath);
获取文件名称,包含扩展名
Path.GetFileName(productPath);
获取文件大小
FileInfo fi = new FileInfo(productPath);
fileSize = fi.Length;
修改文件名
string fileNameWithoutExt = Path.GetFileNameWithoutExtension(productPath);
string guidProductPath = productPath.Replace(fileNameWithoutExt, fileId);
File.Move(productPath, guidProductPath);
判断路径是否有效
File.Exists(productPath)
路径拼接
Path.Combine(…,…)