Files become ReadOnly

M

Miro

Hello

For some strange reasons, some of my files become ReadOnly when I copy them to a subfolder to my ASP.NET application. For each new session I clear the temp folder using this code

private void ClearTempFolder(

//Remove all dwg-files from Tem
String[] dwgFiles = Directory.GetFiles(Server.MapPath(TempPath), "*.dwg")
for (int i=0; i<dwgFiles.Length; i++
File.Delete(dwgFiles)


then the user makes selections on the page and new drawings are copied to the temp folder

private void CopyDWGFileToTemp(

..
if (File.Exists(frompath)

File.Copy(frompath, Server.MapPath(topath), true)

..


Sometimes the ClearTempFolder() function fails with an "Access denied" error. If there are for example four files in the folder, two of them are deleted and the two remaining are ReadOnly, and probably causing the error. Sometimes all files are deleted without problem. This problem seems to occur on Windows 2003 Server only. Any ideas on this one

develop machine: Win XP, Framework 1.1, IIS 5.1, VS.NET 2003 (C#)
Settings: Anonymous Access (IUSR account) and Windows Authentication are checked in IIS. IUSR has full rights on the Temp-folde

Thanks
Miro
 
D

David Coe, MCP

It sounds like you need to declare the FileMode for the file(s) using the FileMode attribute.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,476
Members
44,896
Latest member
PenniGowin

Latest Threads

Top