Newly created file not showing up in filesystem directly

I am using Aspose.Words in an ASP.NET application that is being used by 40+ companies. The application can generate Word documents and / or convert Word documents to PDF. This has worked for over 8 years without any problems. Only recently one client is having some problems and I can’t determine why. I have been unable to reproduce the problem, as it happens randomly. I will try to explain the situation:

I have a ASP.NET datagrid that lists all files in a specific folder. The user can generate a Word document that is being placed in that folder. After generating the Word document they can choose to make a PDF copy. The user also has the option of opening the folder directly (link to network share).

As said, sometimes - not always - the following happens:

  • User creates the new Word document. Page reloads, datagrid shows the Word document.
  • User presses button to make a PDF copy. Page reloads, shows both the Word and the PDF document.
  • User tries to open the PDF document (link to file on network share, f.e. \server\folder\document.pdf), but document can’t be found.
  • User presses link to open the network share in Windows Explorer, only the Word document is there.
  • After a few minutes, or after other activity, the file shows up in Windows Explorer and the user can open the file.

What I don’t understand is that the ASP.NET application can see the file, otherwise it wouldn’t show up in the datagrid, but that the user cannot see the file (or open it).

It is very hard to troubleshoot this problem, because I cannot reproduce it and when the client contacts me when this happens the file usually shows up before we have a teamviewer session up and running, or the file appears the moment I do something.

The code to read the contents of the folder is:


Dim fileInfoArray() As FileInfo = dirInfo.GetFiles("*.*")
Array.Sort(fileInfoArray, New CompareFileInfoEntries(compareMethod))
Me.dgFileList.DataSource = fileInfoArray
Me.dgFileList.Columns(4).Visible = boolPopUp


The code to convert the Word document to a PDF is:


Dim license As License = New License
license.SetLicense(System.Web.HttpContext.Current.Server.MapPath("License") + "\Aspose.Words.lic")

Dim doc As New Aspose.Words.Document(Me.ddlBestandsBeheerDirectories.SelectedValue & strFileName)
doc.Save(String.Format("{0}{1}", Me.ddlBestandsBeheerDirectories.SelectedValue, Replace(strFileName, ".doc", ".pdf")), Aspose.Words.SaveFormat.Pdf)


Is it technically possible that Aspose.Words generates a document that can be seen by the ASP.NET process but not by the client? Could it be that the file is still ‘in use’ by the ASP.NET process and doesn’t show up until it is released? If so, should I ‘close’ the doc object or something?

Hi Niels,

Thanks for your inquiry.

Most probably, you are facing this issue because the process of Doc to Pdf conversion is not completed and user is trying to open Pdf file which has size 0kb. In this scenario, I suggest you please do not load files in the grid which has size 0kb.

You can check the file size before loading it into grid.

FileInfo f = new FileInfo(MyDir + "in.docx");
long size = f.Length;

Hope this answers your query. Please let us know if you have any more queries.

Hi Tahir,

Thank you for your reply. Unfortunately it is not a case of the PDF having a filesize of 0, since the datagrid is showing the correct filesize, for example:

Filename Extension Size Last changed
doc1.doc .doc 38 Kb 10: 12 03 - 05 - 2013
doc1.pdf .pdf 24 Kb 10: 17 03 - 05 - 2013

Both files link to \servername\folder… This folder can be opened from the webpage, but while the DOC file is there, the PDF isn’t.

Since this is the only client that is facing this problem I am inclined to think it might be a network or server issue, but I need to rule out it could be an Aspose / my application problem before I tell them that.

Hi Niels,

Thanks for your inquiry.

You are getting files with dirInfo.GetFiles(".") method and also getting the correct file size. As you have shared that this is working fine for your other customers and your code returns the correct file size so the issue is not related to Aspose.Words. If you get the correct file size from disk, its mean that file exists at disk. Perhaps this issue is related to network or some other issue at server side.

Aspose.Words exports the files correctly so this issue is not related to Aspose.Words. Hope this answers your query. Please let us know if you have any more queries.