在Visual Studio中使用ftp上载时出现问题

时间:2018-08-30 14:09:27

标签: c# ftp

有没有人可以解释我遇到的错误?我收到的错误

  

该进程无法访问文件'C:\ Users \ Roelf \ Documents \ test555.wav',因为该文件正在被另一个进程使用。

一切都关闭了。我什至重新启动了一切。尽管下载过程很有趣。我使用this post作为参考。非常感谢您的帮助(注意:我知道错误告诉我文件正在被其他人使用。问题是我无法弄清楚是什么,因为VS是当前使用它的唯一程序。)

public void UploadAudioFile(string filename)
{
    string path0 = Path.Combine("ftp://vps573557.ovh.net/TranscriptionData/AudioFiles/", filename);
    string path1 = Path.Combine(@"C://Users/Roelf/Documents/Transcriptions/", filename);
    WebClient client = new WebClient();
    client.Credentials = new NetworkCredential("user", "pass");

    client.UploadFile(path0, path1);
}

1 个答案:

答案 0 :(得分:0)

尝试使用:

 using(FileStream stream = new FileStream(fullFileName, FileMode.Create))
 {
     // do something here with your stream
 }

这可以避免这类问题。

相关问题