나는 사용자가 텍스트 상자에 입력 한 폴더의 C 드라이브에서 검색 할 C# windows 응용 프로그램을 만들었습니다. 사용자가 단추를 누르면 검색이 시작됩니다. 나는 C 드라이브의 모든 폴더/파일 (또는 다른 드라이브)를 발견 할 수 있습니까Windows에서 C# 프로그램의 파일 권한을 변경하는 방법?
Access To The Path 'C:\Documents and Settings' is Denied
나는이 액세스 할 수없는, 변화 : 문제는 내가 말해 예외를 얻고 있다는 것입니다 내 C# 프로그램을 통해 권한 부여 또는 무언가에 대한 액세스 권한을 부여 받았기 때문에 검색을 계속할 수 있습니까? 리눅스에서
은 chmod를있다,하지만 난 .. 제발 도와주세요 창 모르는 :
검색 코드 :string operationSucceeded = "Operation Completed Successfully";
Exception NoFilesFound = new Exception("No File(s) Found In Specified Directory");
List<string> foundFolders = new List<string>();
private void button5_Click(object sender, EventArgs e)
{
try
{
Search_In_For("C:\\", WantedFile_Folder_TextBox.Text);
if (foundFolders == null) throw NoFilesFound;
for (int i = 0; i < foundFolders.Count; i++)
SearchResultsTextBox.Text += (foundFolders[i] + "\n");
MessageBox.Show(operationSucceeded);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
delegate void SearchDelegate(string searchDir, string wanted);
private void Search_In_For(string searchDir, string wanted)
{
string[] foldersInThisDir = Directory.GetDirectories(searchDir);
if (foldersInThisDir.Length == 0) return;
for (int i = 0; i < foldersInThisDir.Length; i++)
if (foldersInThisDir[i].Contains(wanted))
foundFolders.Add(foldersInThisDir[i]);
SearchDelegate sd = new SearchDelegate(Search_In_For);
for (int i = 0; i < foldersInThisDir.Length; i++)
sd(foldersInThisDir[i] , wanted);
}
http://stackoverflow.com/questions/4986293/access-to-the-path-is-denied-when-using-directory-getfiles – Anirudha