Win10에서 C# application.exe가 작동하지 않지만 내 Win7에서 작동했습니다. Win10에서 디버깅을 시도했는데 win7에서이 오류가 발생했습니다.C# DirectoryNotFoundException Windows 10 컴퓨터에서 처리되지 않았습니다.
using System;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string fullComputerName = Environment.MachineName;
//Create a Folder Path
string createFolderPath = @"C:\\Users\\" +fullComputerName+"\\Documents\\Cheques";
//Create a File Inside of a Folder
string createTxtFile= createFolderPath + "\\ChequeForDeposit.TXT";
try
{
if(!Directory.Exists(createFolderPath))
{ return; }
Directory.CreateDirectory(createFolderPath);
}
catch { }
finally { }
if(!File.Exists(createTxtFile))
{ File.Create(createTxtFile); }//The error is here
}
}
}
내 win7 pc에서 확인하면 폴더와 텍스트 파일이 만들어집니다. 하지만 Win10에서는 그렇지 않습니다. 그것은 너무 이상합니다.
, 내가 액세스가 거부 THK! – James
win10에서 폴더 & 파일을 생성하지 않습니다. – Vincent
catch (Exception e) {},이 예외가 발생했는지 확인하고 액세스가 거부 되었습니까? – James