I am creating a console application to create a file by checking if the directory and file name exist, my console application will be running in administration mode but I want to perform file exists and file create operations by passing custom users' credentials as input.
if (Directory.Exists(directory))
{
string fullPath = directory + "\demo.txt"
try
{
if (File.Exists(fullPath))
{
File.Delete(fullPath)
}
// here will be my file creation code by taking the custom user credentials as input
}
catch (Exception)
{
success = false;
}
}