srihari kodali

srihari kodali

  • NA
  • 88
  • 1.5k

Hi i am using kernel32.dll for creating the files (pdf file)

Oct 15 2015 9:46 AM
Hi, i am using kernel32.dll for creating the files in my remote server.
 
i am using default function for creating the files as folllows
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
static extern SafeFileHandle CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
Calling the above method by referring safefilehandle class like this,
this.Handle = CreateFile(filePath, GENERIC_ALL, FILE_SHARE_READ, IntPtr.Zero, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero);
 
i was able to create a new file but what i observed is that .exe which i was generating a file was not releasing the file and it is saying that it is in open mode. i was unable to access that file for further modification. 
 
 If i restart my .exe at that time it was releasing the file and i was able to do the things. Only when i was creating a new file it was not releasing. 
 
I am making the handle to close the file. Even then also i was unable to do.
 
This is happening only when i was creating a new pdf file in the remote server. 
 
Since i was struck with this, i need a solution very fast.
 
Thanks in advance. 
 

Answers (2)