Dear visitors,
I have problem when i access the directory.. i get an error like " Access to the path is denied in C#... Can anyone know about this let me know it quickly... My user account for the domain has all permission.. Although i get the same error.. Assist me..
Regards,
Mahesh
Mahendran SubramanianPosted Nov 29, 2007, 3:36 AM
Hi Jason,
Here i enclosed my error code for ur further reference.. plz check it and inform whr i need change..
public static void Unzip()
{
FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.Read, "E:\\Filedownload\\NewFolder1");
f2.AddPathList(FileIOPermissionAccess.Write, "E:\\Filedownload\\NewFolder1");
//FileIOPermission f = new FileIOPermission(PermissionState.Unrestricted);
//f.AllFiles = FileIOPermissionAccess.AllAccess;
string Path = @"E:\Filedownload\DownloadFolder.zip";
string DesPath = @"E:\Filedownload\NewFolder1";
//@"C:\Documents and Settings\Mahesh\Desktop";
FileStream fileIn = new FileStream(Path, FileMode.Open, FileAccess.Read);
ZipInputStream zipInStream = new ZipInputStream(fileIn);
ZipEntry entry = zipInStream.GetNextEntry();
if (Directory.Exists(DesPath))
{
FileStream fileOut = new FileStream(DesPath, FileMode.Create, FileAccess.Write); //The Error occured in this line Specificaclly in "DesPath" arguement
int size;
byte[] buffer = new byte[7100];
do
{
size = zipInStream.Read(buffer, 0, buffer.Length);
fileOut.Write(buffer, 0, size);
} while (size > 0);
zipInStream.Close();
fileOut.Close();
fileIn.Close();
}
Hope u would get my point... Plz do the needful..
Regards,
Mahesh
JasonPosted Nov 28, 2007, 11:28 AM
Mahesh,
It would be helpful to see your code and exactly where the error is occuring. You may need to set credentials in your code, something like:
Me.Credentials = System.Net.CredentialCache.DefaultCredentials
Also you may want to search the forums at www.asp.net for your particular error. The forums there have a lot more traffic.