473,558 Members | 3,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dsolefile issues when file is open through share

I am experiencing problems when one user has a document open through a
share pointing to the web site. I use the dsolefile to read the
contents of a particular directory and then display them in a
datalist. When the next user selects trys to run the page, the page
fails and I get a generic error message from the stack trace. I am
assuming that the document properties cannot be read when a file is
open, but it worked well in asp.

[NullReferenceEx ception: Object reference not set to an instance of an
object.]
DSOleFile.Docum entProperties.g et_Title() +0
DevIntraclean.F ileListingwImag e.Page_Load(Obj ect sender, EventArgs
e)
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +67
System.Web.UI.C ontrol.LoadRecu rsive() +35
System.Web.UI.C ontrol.LoadRecu rsive() +98
System.Web.UI.C ontrol.LoadRecu rsive() +98
System.Web.UI.P age.ProcessRequ estMain() +731

I listed the code below:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

'Set the Image for the Page
headerImage.Ima geUrl = ImagePath

'Create Datatable to Hold File Information
Dim fileListTable As New DataTable
Dim fileListRow As DataRow
fileListTable.C olumns.Add("Nam e")
fileListTable.C olumns.Add("Tit le")
fileListTable.C olumns.Add("Las tModified")
fileListTable.C olumns.Add("Cre ateDate")
fileListTable.C olumns.Add("doc Icon")

'Create Arraylist of OLE File Types
Dim fileOleTypeList As New ArrayList
fileOleTypeList .Add("*.doc")
fileOleTypeList .Add("*.xls")

'Declarations
'ToDo: Commented out the DSOLeFile Line
Dim propReader As New DSOleFile.Prope rtyReader
Dim docProp As DSOleFile.Docum entProperties
Dim i As Integer

'ToDo: Remove this After Location Property Works
Dim docDirectors As New DirectoryInfo(L ocation)

'Loop Through Array List for OLE Objects
For i = 0 To fileOleTypeList .Count - 1
'Loop Through Each File in Folder Directory
For Each file As System.IO.FileI nfo In
docDirectors.Ge tFiles(fileOleT ypeList.Item(i) )
fileListRow = fileListTable.N ewRow
Try
docProp =
propReader.GetD ocumentProperti es(file.FullNam e)
Catch ex As Exception
Dim aLog As EventLog
Dim sMessage As String
aLog = New EventLog
aLog.Source = "DevIntracleanL ocal"
sMessage = ex.Message & " File: " & file.FullName
aLog.WriteEntry (sMessage, EventLogEntryTy pe.Error)
End Try
'Gather File Name for Display
fileListRow.Ite m("Name") = VirtualPath & "" &
file.Name
'Gather File Last Modified for Display
fileListRow.Ite m("LastModified ") = file.LastWriteT ime
'Check to See If document Properties are Valid
If Not docProp Is Nothing Then
'Gather the Document Title if Available for
Display
If docProp.Title <> "" Then
fileListRow.Ite m("Title") = docProp.Title
Else
fileListRow.Ite m("Title") = Replace(file.Na me,
file.Extension, "")
End If
'Gather File Create Date for Display
'fileListRow.It em("CreateDate" ) =
file.CreationTi me
'Gather Image that Matches File Extension for
Display
fileListRow.Ite m("docIcon") =
GetDocumentIcon Image(file)
Else
'Gather the Document Title if Available for
Display use Fill Full Name If OLE not Available
fileListRow.Ite m("Title") = file.FullName
'Gather File Create Date for Display
'fileListRow.It em("CreateDate" ) =
file.CreationTi me
'Gather Image that Matches File Extension for
Display
fileListRow.Ite m("docIcon") =
GetDocumentIcon Image(file)

End If
'Release the com object or File Will Remain Locked
If Not docProp Is Nothing Then
System.Runtime. InteropServices .Marshal.Releas eComObject(docP rop)
End If
'Add File Properties Row to DataTable
fileListTable.R ows.Add(fileLis tRow)

Next

Next
'Release Com object or Files will remain Locked
If Not propReader Is Nothing Then
System.Runtime. InteropServices .Marshal.Releas eComObject(prop Reader)
End If
'Create Arraylist for non OLE Objects
Dim fileTypeList As New ArrayList
fileTypeList.Ad d("*.htm")
fileTypeList.Ad d("*.html")
fileTypeList.Ad d("*.pdf")
fileTypeList.Ad d("*.ppt")
'Loop Through Non Ole File Types
For i = 0 To fileTypeList.Co unt - 1
'Loop Through each file in folder matching search criteria
For Each file As FileInfo In
docDirectors.Ge tFiles(fileType List.Item(i))
'Create New Row in Datatable
fileListRow = fileListTable.N ewRow
'Gather File Name for Link
fileListRow.Ite m("Name") = VirtualPath & "/" &
file.Name
'Gather File Last Modified Date to Display
fileListRow.Ite m("LastModified ") = file.LastWriteT ime
'Gather File Name and Remove extension to Display
fileListRow.Ite m("Title") = Replace(file.Na me,
file.Extension, "")
'Gather Create Date for Display
'fileListRow.It em("CreateDate" ) = file.CreationTi me
'Gather Image that Matches File Extension for Display
fileListRow.Ite m("docIcon") =
GetDocumentIcon Image(file)
'Add Row to Datatable
fileListTable.R ows.Add(fileLis tRow)
'Release com object or file will remain locked
If Not docProp Is Nothing Then
System.Runtime. InteropServices .Marshal.Releas eComObject(docP rop)
End If
Next
Next
'Release com object or file will remain locked

If Not propReader Is Nothing Then
System.Runtime. InteropServices .Marshal.Releas eComObject(prop Reader)
End If
'Set Datalist datasource and bind
dlFileListing.D ataSource = fileListTable
dlFileListing.D ataBind()

End Sub
Nov 20 '05 #1
0 2546

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1558
by: Jeffrey | last post by:
Good day all, I have seen so many postings dealing with MS Access as a security risk and other items, yet I see now clear reason why. I would really like someone to point me in the right direction for clear reasons why MS Access should not be used for the enterprise. For a handful of users I don't see an issue, but when an access...
6
5137
by: Ana | last post by:
Hi! I have problems with the following scenario: My application is developed using C# under .NET. It must run on all Windows versions starting from Windows 98. The user must open different documents (txt, MS Office files, pdf, pictures,…) from inside my app. It must start the file with the adequate external program (Notepad, MS Office...
0
1246
by: Jason | last post by:
I am porting some legacy services to C# and .NET. I have run across two issues with using DSOLEFILE in .NET, and was hoping somebody might shed some light... 1. Access Files Across the Network My application is a service. I am able to use File.Exists to confirm the existence of a file, but when I do someting like: PropertyReader...
3
3548
by: Steve Lang | last post by:
Hi all, I am trying to use the DSOleFile.dll in my VB.NET application (that I am converting from VB6) to extract some property data from a Word document before the application processes the file. The key feature of the dll is that it allows the data to be extracted without the document opening in Word; I successfully used it in VB6 without...
0
346
by: troutbum | last post by:
I am listing the contents of a directory, everything seems to work fine. However, I created a share to the folder in the web for content management purposes. When any user opens the file in the share the following code fails due to permissions. 'Set the Image for the Page headerImage.ImageUrl = ImagePath 'Create Datatable to Hold File...
4
11141
by: Paul Bromley | last post by:
I have been pondering over this one all night!! I want to read the properties of a Word document WITHOUT opening it - notably the title document. Having read the newsgroups it seems that I neede to download from the MS site the DSOFile package containing the said DLL. However on looking in the newsgroups the best option to me seems to be using...
0
1256
by: Henrik | last post by:
Hi, I'm trying to set CustomProperties through the newer version of the DSOleFile (2.x) object for Word, Excel and PowerPoint documents. For some reason it seems that when I'm trying to set a custom property to an empty string ("") it will simply cause all the other existing properties including the newly created on to disappear when trying...
1
3881
by: Billy | last post by:
Hi All, I'm attempting to use the MapNetworkDrive <snippedbelow from entire code below with very poor performance results. Basically, I have very small 73kb text files that are rewritten daily to a network share using the MapNetworkDrive command to connect to the valid \\servername\share path. After successfully connecting the drive in...
5
5355
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am trying to accesss a Mapped Drive from my asp.net code running on IIS 6.0. I am using a FileUpload control and fileUpload.SaveAs() to save the file to the server. I want to save the file to a mapped drive that is mapped to a share on the network. When I save to "C:\temp\myFile.txt it works but when I save to Z:\temp\myFile.txt is will...
0
7629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8061
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7593
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5455
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5172
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3603
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
872
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.