On Jun 30, 2:51*pm, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.com> wrote:
> "fyitang" wrote:
> > On Jun 30, 1:06 pm, Morten Wennevik [C# MVP]
> > <MortenWenne...@hotmail.com> wrote:
> > > Hi,
>
> > > Could you show is what you do to the file? *FileInfo does not block file
> > > deletion in any way and "access to path" denied would indicate you assemble
> > > the file path in some way or other or move files. *Are you using thesame
> > > file name after deleting the file? *We need more information to be able to
> > > give any better answers.
>
> > > --
> > > Happy Coding!
> > > Morten Wennevik [C# MVP]
>
> > > "fyitang" wrote:
> > > > hi guys, here is the sample:
>
> > > > string strFileFullName = "";
> > > > try
> > > > {
> > > > * FileInfo currentFile = GetOneFile("some directory");
> > > > * strFileFullName = currentFile.FullName;
>
> > > > * // do someting...
>
> > > > * currentFile.Delete();
> > > > }
> > > > catch(exception ex)
> > > > {
> > > > * savelog(ex);
> > > > * File.Move(strFileFullName, "some backup folder and file name");
> > > > }
>
> > > > these codes are executed by a timer_click event, the timer keep
> > > > monitoring some folder, and processing the files one by one. my
> > > > question is: why i meet some exception "access to the path '' denied"
> > > > occasionally, and why these "exception file" can be moved to my backup
> > > > folder? mostly no exception happend. thanks in advance.- Hide quotedtext -
>
> > > - Show quoted text -
>
> > hi Morten,
> > what i do to the file can be simplified as 2 steps:
> > 1. load the file into memory, then create an instance of one class( we
> > can say Sample aSample = new Sample) based on the content of the file.
> > 2. process the instance aSample, no related to the file any more after
> > load finished.
>
> > and yeah, fileinfo does not block the file, so most files can be
> > processed successfully. and i used the same file name when backuping
> > the exception files, it worked.
>
> Hi,
>
> This is still a bit too vague to give any good answers. *If you can give
> exact code snippets (remove/rename sensitive data) it would be much easierto
> guess or even spot the error.
>
> Somewhere along the line you end up with a non existant, permission
> restricted or locked file or folder. *Perhaps a file with spaces is causing
> part of the file name to be treated as a folder. *In case of web application
> it is also easy to get folder access denied if you stray outside specific
> folder permissions.
>
> --
> Happy Coding!
> Morten Wennevik [C# MVP]- Hide quoted text -
>
> - Show quoted text -
thanks Morten, because the real process is complicated, it is hard to
abstract them, i'll try. btw, my software is a desktop application,
not web's.
|