“进程无法访问文件”问题 [英] "Process cannot access file" problem

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

问题描述



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

推荐答案

我的filewatch程序有类似的问题。当我在缩略图或幻灯片模式下在该目录上打开

窗口时,就会发生这种情况。我还有一个

小费,关于在移动之前检查文件是否完成。尝试打开文件。

我还没有测试过小费。


Petter L


" Paul" ; < PR ***** @ mail.com>在消息中写道

news:41 *********************** @ mercury.nildram.net ...
I had simular problems with my filewatch program. It happend when I had a
window open on that directory in thumbnail or filmstrip mode. I also got a
tip about check if the file is finished before move it. try opend the file.
I have not tested the tip yet.

Petter L

"Paul" <pr*****@mail.com> wrote in message
news:41***********************@mercury.nildram.net ...

VB.NET说我正在创建的文件正被另一个进程使用,并且
无法完成将文件移动到指定目的地的任务
文件夹。
这是我的代码(无论如何都是主要的)....

Private Sub LogChange(ByVal source As Object,ByVal e As
System.IO.FileSystemEventArgs)
如果e.ChangeType = WatcherChangeTypes.Created那么
System.IO.File.Move(e.FullPath,textBoxDest.Text&" \"& e.Name)
结束如果

e.FullPath返回创建文件的完整路径和文件名,例如
c:\ filename.txt
textboxDest是文件移动到的位置,例如D:\
e.Name是没有路径的文件名,例如filename.txt

这是错误文本......

System.IO.IOException:进程无法访问文件
D:\未分类\2005\New.mp3"因为它正在被另一个进程使用。
文件被下载到由FileSystemWatcher监视的D:\ Unnsorted \文件夹中会发生什么。该应用程序然后尝试将
下载/创建的文件移动到D:\ Unnsorted \ 20055 \文件夹,然后发生错误


任何帮助非常感谢,
谢谢
保罗
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



嗨再次


我第一次接受后,我得到了在我的程序中再次出现问题。当我在复制动作之前暂停
然后踩了它时,它的工作时间大部分都是

但是如果我让程序运行它创建了一个进程无法访问

档案它指向文件的目标路径。我做的是




System.Threading.Thread.Sleep(5000)


之前复制例程,现在它工作正常。


也许这对你的问题也有帮助吗?


Petter L.


" Paul" < PR ***** @ mail.com>在消息中写道

news:41 *********************** @ mercury.nildram.net ...
Hi again

Right after my first nessage I got the problem again in my program. When I
halted right before the copy action and steped though it, it worked most of
the times but if i let the program run it created a "Process cannot access
file" and it pointed to the destination path for the file. What i did was to
put

System.Threading.Thread.Sleep(5000)

before the copy routine and now it works fine.

Maybe this can help on your problem too ?

Petter L.

"Paul" <pr*****@mail.com> wrote in message
news:41***********************@mercury.nildram.net ...

VB.NET说我正在创建的文件正被另一个进程使用,并且
无法完成将文件移动到指定目的地的任务
文件夹。
这是我的代码(无论如何都是主要的)....

Private Sub LogChange(ByVal source As Object,ByVal e As
System.IO.FileSystemEventArgs)
如果e.ChangeType = WatcherChangeTypes.Created那么
System.IO.File.Move(e.FullPath,textBoxDest.Text&" \"& e.Name)
结束如果

e.FullPath返回创建文件的完整路径和文件名,例如
c:\ filename.txt
textboxDest是文件移动到的位置,例如D:\
e.Name是没有路径的文件名,例如filename.txt

这是错误文本......

System.IO.IOException:进程无法访问文件
D:\未分类\2005\New.mp3"因为它正在被另一个进程使用。
文件被下载到由FileSystemWatcher监视的D:\ Unnsorted \文件夹中会发生什么。该应用程序然后尝试将
下载/创建的文件移动到D:\ Unnsorted \ 20055 \文件夹,然后发生错误


任何帮助非常感谢,
谢谢
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



感谢小费Petter。它也适用于我的问题,但我更愿意

使用更好的方法,如果一个人知道。


是否可以锁定正在移动的文件没有其他进程可以

访问该文件?例如。 Windows尝试提取缩略图,ID3标签等。


谢谢,

Paul


" petterl" < PE ********** @ hotmail.com>在消息中写道

news:u2 ************** @ TK2MSFTNGP12.phx.gbl ...
Thanks for the tip Petter. It works on my problem too but I would prefer to
use a better way if one is known.

Is it possible to lock the file being moved so that no other process can
access the file? E.g. Windows trying to extract thumbnail, ID3 tag etc.

Thanks,
Paul

"petterl" <pe**********@hotmail.com> wrote in message
news:u2**************@TK2MSFTNGP12.phx.gbl...
嗨再次

在我第一次使用后,我在程序中再次遇到问题。当我在复制动作之前暂停并且通过它时,它最有效,但是如果我让程序运行它创建了一个进程无法访问文件。它指向文件的目标路径。我做的是在复制例程之前放置

System.Threading.Thread.Sleep(5000)
,现在它工作正常。

也许这对你的问题也有帮助吗?

Petter L.

保罗 < PR ***** @ mail.com>在消息中写道
新闻:41 *********************** @ mercury.nildram.net ...
Hi again

Right after my first nessage I got the problem again in my program. When I
halted right before the copy action and steped though it, it worked most
of the times but if i let the program run it created a "Process cannot
access file" and it pointed to the destination path for the file. What i
did was to put

System.Threading.Thread.Sleep(5000)

before the copy routine and now it works fine.

Maybe this can help on your problem too ?

Petter L.

"Paul" <pr*****@mail.com> wrote in message
news:41***********************@mercury.nildram.net ...

VB.NET说我正在创建的文件正由另一个进程使用,并且
无法完成将文件移动到指定目标
文件夹的任务。这是我的代码(无论如何都是主要的)....

Private Sub LogChange(ByVal source As Object,ByVal e As
System.IO.FileSystemEventArgs)
如果e.ChangeType = WatcherChangeTypes.Created那么
System.IO.File.Move(e.FullPath,textBoxDest.Text&" \"& e.Name)
结束如果

e.FullPath返回创建的文件的完整路径和文件名,例如
c:\ filename.txt
textboxDest是将文件移动到的位置,例如D:\
e.Name是没有路径的文件名,例如filename.txt

这是错误文本......

System.IO.IOException:进程无法访问文件
D:\未分类\2005\New.mp3"因为它正在被另一个进程使用。
文件被下载到由FileSystemWatcher监视的D:\ Unnsorted \文件夹中会发生什么。该应用程序然后尝试将
下载/创建的文件移动到D:\ Unnsorted \ 20055 \文件夹,然后发生错误


任何帮助非常感谢,
谢谢
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




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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆