I wanna code to know if file is critical system file (like CONFIG.SYS , NTDETECT.COM , autoexec.bat)
I tried to use code to get file attributes and see if the file has "System" attribute but i found files like autoexec.bat hasn't "system" attribute.
I try to use that C# code but it doesn't work too (Every Time it gives me "True" value)
public static string isFileSystem(string FileName)
{
try
{
Type oType = Type.GetTypeFromProgID("Shell.Application");
object objShell = Activator.CreateInstance(oType);
object objFolder = oType.InvokeMember("Namespace", System.Reflection.BindingFlags.InvokeMethod, null, objShell, new object[] { new FileInfo(FileName).DirectoryName });
object objFolderItem = oType.InvokeMember("ParseName", System.Reflection.BindingFlags.InvokeMethod, null, objFolder, new object[] { new FileInfo(FileName).Name });
return oType.InvokeMember("isFileSystem", System.Reflection.BindingFlags.GetProperty, null, objFolderItem , null).ToString();
}
catch { return ""; }
}
The Same code in VB.NET (without Blinding Codes) is
Public Shared Function isFileSystem(ByVal FileName As String) As String
Try
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(new FileInfo(FileName).DirectoryName)
Set objFolderItem = objFolder.ParseName(new FileInfo(FileName).Name)
Return objFolderItem.IsFileSystem.ToString
Catch
Return ""
End Try
End Function
I don't know where is the error.
If you have any other code can do the same task without too long codes it'll be good.
Question
N_Win_Member
I wanna code to know if file is critical system file (like CONFIG.SYS , NTDETECT.COM , autoexec.bat)
I tried to use code to get file attributes and see if the file has "System" attribute but i found files like autoexec.bat hasn't "system" attribute.
I try to use that C# code but it doesn't work too (Every Time it gives me "True" value)
The Same code in VB.NET (without Blinding Codes) is
I don't know where is the error.
If you have any other code can do the same task without too long codes it'll be good.
Link to comment
https://www.neowin.net/forum/topic/525457-determine-if-file-is-critical-system-file-how/Share on other sites
12 answers to this question
Recommended Posts