dotnet sdk:
Hello, In the first method, if you change the extension ":eDB" to a normal one, like ".map": IntPtr Handle = Win32.CreateFile(m_Path + ".map", Win32.GENERIC_WRITE, 0, IntPtr.Zero, Win32.OPEN_ALWAYS, 0, IntPtr.Zero); Will it be success? ":eDB" seems not be a common string used for file extension. Also, if you change the code like: FileStream outStream2 = new FileStream(m_Path + ":eDB", FileMode.Create, FileAccess.Write); Will this also cause the problem? Luke
I am having problems with the following method in a Serializable class: public void SaveMap() { // Three different ways to open a file // a) With a handle to an extended attribute on file m_Path (Which is a directory) // b) With a handle to a file in the directory m_Path // c) Opened from a filespec to a file in the directory m_Path // I wish for the (a) version to work correctly IntPtr Handle = Win32.CreateFile(m_Path + ":eDB", Win32.GENERIC_WRITE, 0, IntPtr.Zero, Win32.OPEN_ALWAYS, 0, IntPtr.Zero); IntPtr Handle2 = Win32.CreateFile(m_Path + "-.map", Win32.GENERIC_WRITE, 0, IntPtr.Zero, Win32.OPEN_ALWAYS, 0, IntPtr.Zero); FileStream outStream = new FileStream(Handle, FileAccess.Write, true); FileStream outStream3 = new FileStream(Handle2, FileAccess.Write, true); FileStream outStream2 = new FileStream(m_Path + ".map", FileMode.Create, FileAccess.Write); XmlSerializer XMLformat = new XmlSerializer(typeof(DropBoxMap), "DropBoxMap"); // Serialize the object to all three files XMLformat.Serialize(outStream3, this); XMLformat.Serialize(outStream2, this); XMLformat.Serialize(outStream, this); // Close all three files outStream.Close(); outStream2.Close(); outStream3.Close(); } After I step through this method I diff all three files. The files: m_Path + ".map" and m_Path + "-".map" are identical (These are going to regular files) The file m_Path + ":eDB" has some garbage at the end of the file. This is the extended attribute. This file has the same contents as the previous two, except it has some garbage at the end. It looks like the final flush was executed twice. A part of the end of the file was repeated. A tail of the good file is: <Created>2005-10-19T09:14:37.446856-05:00</Created> <Modified>2005-10-19T09:14:37.446856-05:00</Modified> <SequenceID>2</SequenceID> <SyncState>Current</SyncState> </Elements> <m_Path>C:\Documents and Settings\rschaefer\Desktop\Fred</m_Path> <NextNodeID>5</NextNodeID> <Dirty>true</Dirty> </DropBoxMap> A tail of the extended attribuge file is: <Created>2005-10-19T09:14:37.446856-05:00</Created> <Modified>2005-10-19T09:14:37.446856-05:00</Modified> <SequenceID>2</SequenceID> <SyncState>Current</SyncState> </Elements> <m_Path>C:\Documents and Settings\rschaefer\Desktop\Fred</m_Path> <NextNodeID>5</NextNodeID> <Dirty>true</Dirty> </DropBoxMap>irty> </DropBoxMap>xMap> Of course it refuses to Deserialize with this junk at the end of the file! Any suggestions on how to workaround this ?
It does work. That's case 2 and 3. the :eDB extension to an existing file creates and Extended Attribute to an EXISTING file. (I am not trying to create a file with an extension of :eDB). You can create a file: c:\foo.txt You can use a text editor to view and enter contexts to it. You can also an additional attribute call bar by editing the file: c:\foo.txt:bar The value of the "bar" attribute of file "c:\foo.txt" is the content you put into it. [quoted text, click to view] [MSFT] wrote: > Hello, > > In the first method, if you change the extension ":eDB" to a normal one, > like ".map": > > IntPtr Handle = Win32.CreateFile(m_Path + ".map", > Win32.GENERIC_WRITE, > 0, > IntPtr.Zero, > Win32.OPEN_ALWAYS, > 0, > IntPtr.Zero); > > Will it be success? ":eDB" seems not be a common string used for file > extension. Also, if you change the code like: > > FileStream outStream2 = new FileStream(m_Path + ":eDB", FileMode.Create, > FileAccess.Write); > > Will this also cause the problem? > > Luke
It does work. That's case 2 and 3. the :eDB extension to an existing file creates and Extended Attribute to an EXISTING file. (I am not trying to create a file with an extension of :eDB). You can create a file: c:\foo.txt You can use a text editor to view and enter contexts to it. You can also an additional attribute call bar by editing the file: c:\foo.txt:bar The value of the "bar" attribute of file "c:\foo.txt" is the content you put into it. [quoted text, click to view] [MSFT] wrote: > Hello, > > In the first method, if you change the extension ":eDB" to a normal one, > like ".map": > > IntPtr Handle = Win32.CreateFile(m_Path + ".map", > Win32.GENERIC_WRITE, > 0, > IntPtr.Zero, > Win32.OPEN_ALWAYS, > 0, > IntPtr.Zero); > > Will it be success? ":eDB" seems not be a common string used for file > extension. Also, if you change the code like: > > FileStream outStream2 = new FileStream(m_Path + ":eDB", FileMode.Create, > FileAccess.Write); > > Will this also cause the problem? > > Luke
It does work. That's case 2 and 3. the :eDB extension to an existing file creates and Extended Attribute to an EXISTING file. (I am not trying to create a file with an extension of :eDB). You can create a file: c:\foo.txt You can use a text editor to view and enter contexts to it. You can also an additional attribute call bar by editing the file: c:\foo.txt:bar The value of the "bar" attribute of file "c:\foo.txt" is the content you put into it. [quoted text, click to view] [MSFT] wrote: > Hello, > > In the first method, if you change the extension ":eDB" to a normal one, > like ".map": > > IntPtr Handle = Win32.CreateFile(m_Path + ".map", > Win32.GENERIC_WRITE, > 0, > IntPtr.Zero, > Win32.OPEN_ALWAYS, > 0, > IntPtr.Zero); > > Will it be success? ":eDB" seems not be a common string used for file > extension. Also, if you change the code like: > > FileStream outStream2 = new FileStream(m_Path + ":eDB", FileMode.Create, > FileAccess.Write); > > Will this also cause the problem? > > Luke
Hi Rich, Thanks for your feedback. Which platform are you using? With searching "extended attribute" and CreateFile in MSDN, I can not get much information regarding this usage. Can you provide some official documet regarding the "extended attribute"? Currently, I am not sure if this is the standard way of doing this. Thanks Best regards, Jeffrey Tan Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights.
Don't see what you're looking for? Try a search.
|