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 0 2570 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 application (I use that
loosly) drags down the network and the SQL Server at the same time, it
makes me...
|
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 programs, Acrobat Reader, some Picture
viewer,... ) and be notified when this programs closes the...
|
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 objReader = new PropertyReader();
|
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 a problem.
Under .NET, however, after I use a function that calls the dll, the function
appears...
|
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 Information
Dim fileListTable As New DataTable
| |
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 the
DSOleFile.PropertyReader and then the GetDocumentProperties property, but
this seems to be...
|
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 to look at them by right
clicking on properties on the file in Windows the choosing the properties...
|
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 the ASP code, the text file
|
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 not work. I also want to copy, delete and
move these files.
I have found some pages on the net...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |