Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to create a folder, which is should be access denied when I try to open that folder, and also I want to download a file from the server into that folder.

I tried many ways, but folder is not access denied,

C#
string sourcepath = @"c:\current";
string path = @"c:\path";
if (!System.IO.Directory.Exists(path)) // check if folder exist
{
     System.IO.Directory.CreateDirectory(path); 
     string[] files = System.IO.Directory.GetFiles(sourcepath);

     foreach (string f in files)
     {
          // Remove path from the file name. 
          string fName = f.Substring(sourcepath.Length + 1);
          // Use the Path.Combine method to safely append the file name to the path. 
          // Will overwrite if the destination file already exists.
          File.Copy(Path.Combine(sourcepath, fName), Path.Combine(path, fName), true);
     }
}


This is my code and it will work fine, and creates a folder, but I can open that folder because it is not access denied, but my requirement is that folder should not be able to open, it should be access denied.



Thanks in Advance.
Posted
Updated 15-Sep-14 21:25pm
v2

1 solution

Ever since .NET 2.0 there is a class for such thing[^]

Please do some research before asking a question!
 
Share this answer
 
v2
Comments
Aboobakkar Siddeq D U 15-Sep-14 2:52am    
Yes I did many research from last week, and I didn't get any solution to make access denied folder.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900