473,385 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Access to the path '' denied when doing fileinfo.delete()

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.
Jun 30 '08 #1
6 6980
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 the same
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.
Jun 30 '08 #2
On Sun, 29 Jun 2008 20:32:22 -0700, fyitang wrote:
>
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.
Is the file actually open at the time of the delete. This has happened
to me.

Ken

Jun 30 '08 #3
On Jun 30, 1:26*pm, Ken Foskey <fos...@optushome.com.auwrote:
On Sun, 29 Jun 2008 20:32:22 -0700, fyitang wrote:
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.

Is the file actually open at the time of the delete. *This has happened
to me.

Ken
hi ken,
i guess if the file is opend, then the exception message i got would
be "The process cannot access the file '' because it is being used by
another process.". i have tried to do someting to avoid this issue.
Jun 30 '08 #4
On Jun 30, 1:06*pm, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.comwrote:
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 the same
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 quoted text -

- 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.
Jun 30 '08 #5

"fyitang" wrote:
On Jun 30, 1:06 pm, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.comwrote:
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 the same
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 quoted text -
- 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 easier to
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]

Jun 30 '08 #6
On Jun 30, 2:51*pm, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.comwrote:
"fyitang" wrote:
On Jun 30, 1:06 pm, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.comwrote:
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.
Jun 30 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Stan | last post by:
Here is my scenario: Web server ------------ Framework 1.1 Application proxy for the serviced component Component server ------------------- Framework 1.0
5
by: Don Hans | last post by:
Gents, Have .Net2003 Enterprise architect installed on a Win2k Server with IIS. Even logged in as administrator, I cannot run any ASP.NET app with debugging. I always get the error "Unable to...
0
by: John Dalberg | last post by:
I am getting the error below many times when I am trying to use the Enterprise Library. The solution seems to be a reboot. I am using Windows 2003 as my dev box. The error also happens with other...
0
by: Kirk | last post by:
The following C# web service works fine until you uncomment the lines setting UserName and Password. Then, Process.Start throws an Access is Denied Exception. This is with .NET 2.0, of course...
0
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. I'm using System.Web.Mail to compose and send a message. I'm receiving an "Access is denied" error message when non-Domain Administrators attach files to the MailMessage. My allows users...
1
by: Robert Strickland | last post by:
I have a .Net web service (written for 1.1 Framework using C#) running on Windows 2003 with all latest patches. To help monitor the service, the code creates several performance counters. One...
1
by: ssshhh | last post by:
hi y'all! here i am again with another problem: declare @path varchar (100) declare @filename varchar (100) delcare @delete_this varchar (100) declare @cmd varchar (100) set @path =...
3
by: ysakaed | last post by:
Hi I am trying to get the content of the iframe to replace the content inside a div here is the code i use. function changeContent(content) { var buf = content + "_2"; var iframe =...
0
by: dmihailescu | last post by:
the P/Invoke SetWindowLong failed with 'Access is denied' when invoked from a windows service. The service runs under the System account with the 'allow user to interact with the desktop' checked....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.