本文介绍了“进程无法访问文件”问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



VB.NET说我正在创建的文件正由另一个进程使用而且

不会完成将文件移动到的任务指定的目的地

文件夹。

这是我的代码(无论如何都是主要的)....

Private Sub LogChange(ByVal source As Object,ByVal e As

System.IO.FileSystemEventArgs)

如果e.ChangeType = WatcherChangeTypes.Created那么

System.IO.File。移动(e.FullPath,textBoxDest.Text&" \"& e.Name)

结束如果

e.FullPath返回完整路径和文件名创建的文件例如

c:\ filename.txt

textboxDest是文件移动到的位置,例如D:\

e.Name是没有路径的文件名,例如filename.txt


这是错误文本...


System.IO.IOException:进程无法访问文件

" D:\ Unnsorted\2005 \New.mp3"因为它正被另一个进程使用。

文件被下载到D:\ Unnsorted \文件夹会发生什么,这是由FileSystemWatcher监视的
。该应用程序然后尝试将

下载/创建的文件移动到D:\ Unnsorted \\\2005 \文件夹,然后出现错误




任何帮助非常感谢,

谢谢

Paul

Hi,
VB.NET is saying the file I am creating is in use by another process and
won''t complete its task of moving the file to the specified destination
folder.
Here is my code (the main bit anyway)....
Private Sub LogChange(ByVal source As Object, ByVal e As
System.IO.FileSystemEventArgs)
If e.ChangeType = WatcherChangeTypes.Created Then
System.IO.File.Move(e.FullPath, textBoxDest.Text & "\" & e.Name)
End If
e.FullPath returns the full path and filename of the file created e.g
c:\filename.txt
textboxDest is where the file is to be moved to e.g D:\
e.Name is the filename without the path e.g. filename.txt

This is the error text...

System.IO.IOException: The process cannot access the file
"D:\Unsorted\2005\New.mp3" because it is being used by another process.
What happens is files get downloaded to the D:\Unsorted\ folder which is
being monitored by the FileSystemWatcher. The app then tries to move the
downloaded/created file to the D:\Unsorted\2005\ folder then the error
occurs.

Any help much appreciated,
Thanks
Paul

推荐答案








这篇关于“进程无法访问文件”问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 08:18