I see a function UnpackAndInstall, after looking the function, it seems using FindResource to get the resource, and this invoke me some other question.I saw another third-party usbsniffer recently, and its ui is written by c sharp, but when I compile its source code, it
can not load its sysfile, however the exe file the web it provided can work well.
the error come from the following codes:
private static bool ExtractDriverFiles(out string mydir)
{
string tempdir = Path.GetTempPath();
// This needs to be the same dir for uninstall (dpinst not cool here)
mydir = Path.Combine(tempdir, "xxx_temp");
try
{
Directory.CreateDirectory(mydir);
WriteDrverFile(sysFile, mydir);
WriteDrverFile(infFile, mydir);
WriteDrverFile(coinstFile, mydir);
WriteDrverFile(dpinstFile, mydir);
}
catch
{
return false;
}
return true;
}
private static void WriteDrverFile(string resname, string dir)
{
Assembly ass = Assembly.GetExecutingAssembly();
ResourceManager rm = new ResourceManager("xxx.driver", ass);
ResourceSet set = rm.GetResourceSet(CultureInfo.CurrentCulture, true, true);
byte[] buf = (byte[])set.GetObject(resname);
Stream w = File.OpenWrite(Path.Combine(dir, resname));
w.Write(buf, 0, buf.Length);
w.Flush();
w.Close();
}
and the error comes from the following two caluse
ResourceManager rm = new ResourceManager("xxx.driver", ass);
ResourceSet set = rm.GetResourceSet(CultureInfo.CurrentCulture, true, true);
I still can not figure out the problem, and how to make sure the problem it is from and how to handle it,
thanks.