I'd like to get CreateFile handle when I open a volume "C:\\" but I always get -1
I test this in C++ I get 0xffffffff
Can someone shed a light on this for me please ?
Thanks :D
Kim Tu
Printable View
I'd like to get CreateFile handle when I open a volume "C:\\" but I always get -1
I test this in C++ I get 0xffffffff
Can someone shed a light on this for me please ?
Thanks :D
Kim Tu
That's because it's a directory and not a file...
Darwen.
0xffffffff is the same value as -1 for Int32.
Negative numbers are represented in 2's complement. The rule is like this: Represent the absolute value in binary then invert all bits then add 1.
-1 = 0000 0000 0000 0000 0000 0000 0000 0001
then invert
1111 1111 1111 1111 1111 1111 1111 1110
then add 1
1111 1111 1111 1111 1111 1111 1111 1111
and that is 0xffffffff.
good hint Cilu on 2's complement
Try this:
namespace CSCreateFile
{
class Program
{
static void Main(string[] args)
{
string filePath, fileName;
filePath = "D:\\testDirectory\\";
fileName = filePath + "test.txt";
Directory.CreateDirectory(filePath);
File.Create(fileName);
}
}
}
-Ricky
It is @"\\.\C:" not @"C:\"
Enjoy coding! :D
it is what???