PD4ML pd4ml = new PD4ML();
pd4ml.enableTableBreaks(true);
pd4ml.PageInsets = new System.Drawing.Rectangle(5, 5, 5, 5);
pd4ml.PageSize = PD4Constants.getSizeByName("LETTER");
Byte[] byteArray = Encoding.ASCII.GetBytes(content);
MemoryStream stream = new MemoryStream(byteArray);
FinalPath = FinalPath + @"\" + VersionID;
if (!Directory.Exists(FinalPath))
Directory.CreateDirectory(FinalPath);
string FileName = FinalPath +FileName+ ".pdf";
pd4ml.render(stream,new System.IO.FileStream(FileName, System.IO.FileMode.CreateNew));
stream.Flush();
stream.Close();
stream.Dispose();
//In another method I'm opening this file
File stream fs = File.Open(path, FileMode.Open, FileAccess.Read);`
I'm generating PDF using pd4ml.render() method. When I create this file using render method it is opened somewhere in system internally. That's why when I tried to open it mannualy using Filestream fs=new Filestream(path,FileMode.Open,FileAccess.Read)
It throws and exception of file is being used by another process. Please guide me what to do.
I've already used FileShare.ReadWrite attribute and File.OpenRead(path) with my code but it doesn't work for me.