我有下面的C#代码:C#文件访问错误
string selectedFile = "D:\..\IMGP2695.JPG";
MyImage myImage = new MyImage();
Image image = Image.FromFile(selectedFile);
string thumbnail_name = CreateThumbnail(image);
myImage.height = image.Height + "px";
myImage.width = image.Width + "px";
ftp.upload(myImage.internalName, selectedFile, directory);
The process cannot access the file `'D:\..\IMGP2695.JPG'` because it is being used by another process.
我得到这个错误时,该代码尝试运行ftp.upload
。我知道错误意味着什么,但我不知道该如何处理打开的文件。
你为什么要打开它摆在首位? – 2013-04-11 08:08:23
该文件是OpenFileDialog的结果。我没有明确地打开它。 – 2013-04-11 08:09:26