PC Review


Reply
Thread Tools Rate Thread

dsolefile issues when file is open through share

 
 
troutbum
Guest
Posts: n/a
 
      6th Aug 2004
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
Dim fileListRow As DataRow
fileListTable.Columns.Add("Name")
fileListTable.Columns.Add("Title")
fileListTable.Columns.Add("LastModified")
fileListTable.Columns.Add("CreateDate")
fileListTable.Columns.Add("docIcon")

'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.PropertyReader
Dim docProp As DSOleFile.DocumentProperties
Dim i As Integer

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

'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.FileInfo In
docDirectors.GetFiles(fileOleTypeList.Item(i))
fileListRow = fileListTable.NewRow
Try
docProp =
propReader.GetDocumentProperties(file.FullName)
Catch ex As Exception
Dim aLog As EventLog
Dim sMessage As String
aLog = New EventLog
aLog.Source = "DevIntracleanLocal"
sMessage = ex.Message & " File: " & file.FullName
aLog.WriteEntry(sMessage, EventLogEntryType.Error)
End Try
'Gather File Name for Display
fileListRow.Item("Name") = VirtualPath & "" &
file.Name
'Gather File Last Modified for Display
fileListRow.Item("LastModified") = file.LastWriteTime
'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.Item("Title") = docProp.Title
Else
fileListRow.Item("Title") = Replace(file.Name,
file.Extension, "")
End If
'Gather File Create Date for Display
'fileListRow.Item("CreateDate") =
file.CreationTime
'Gather Image that Matches File Extension for
Display
fileListRow.Item("docIcon") =
GetDocumentIconImage(file)
Else
'Gather the Document Title if Available for
Display use Fill Full Name If OLE not Available
fileListRow.Item("Title") = file.FullName
'Gather File Create Date for Display
'fileListRow.Item("CreateDate") =
file.CreationTime
'Gather Image that Matches File Extension for
Display
fileListRow.Item("docIcon") =
GetDocumentIconImage(file)

End If
'Release the com object or File Will Remain Locked
If Not docProp Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(docProp)
End If
'Add File Properties Row to DataTable
fileListTable.Rows.Add(fileListRow)

Next

Next
'Release Com object or Files will remain Locked
If Not propReader Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(propReader)
End If
'Create Arraylist for non OLE Objects
Dim fileTypeList As New ArrayList
fileTypeList.Add("*.htm")
fileTypeList.Add("*.html")
fileTypeList.Add("*.pdf")
fileTypeList.Add("*.ppt")
'Loop Through Non Ole File Types
For i = 0 To fileTypeList.Count - 1
'Loop Through each file in folder matching search criteria
For Each file As FileInfo In
docDirectors.GetFiles(fileTypeList.Item(i))
'Create New Row in Datatable
fileListRow = fileListTable.NewRow
'Gather File Name for Link
fileListRow.Item("Name") = VirtualPath & "/" &
file.Name
'Gather File Last Modified Date to Display
fileListRow.Item("LastModified") = file.LastWriteTime
'Gather File Name and Remove extension to Display
fileListRow.Item("Title") = Replace(file.Name,
file.Extension, "")
'Gather Create Date for Display
'fileListRow.Item("CreateDate") = file.CreationTime
'Gather Image that Matches File Extension for Display
fileListRow.Item("docIcon") =
GetDocumentIconImage(file)
'Add Row to Datatable
fileListTable.Rows.Add(fileListRow)
'Release com object or file will remain locked
If Not docProp Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(docProp)
End If
Next
Next
'Release com object or file will remain locked

If Not propReader Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(propReader)
End If
'Set Datalist datasource and bind
dlFileListing.DataSource = fileListTable
dlFileListing.DataBind()
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Share Issues With 32 bit and 64 bit Vista Jonboy666 Security Networking 2 11th Dec 2008 06:08 PM
Microsoft Money file issues over share Jamie Windows Vista Networking 1 23rd Jan 2008 01:40 PM
dsolefile issues when file is open through share troutbum Microsoft VB .NET 0 29th Jul 2004 01:06 PM
Using DSOleFile to read double-byte character file DevUser Microsoft Dot NET Framework 0 5th May 2004 03:44 AM
P2P File Share issues Steve-o Windows XP Networking 2 26th Feb 2004 08:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:32 PM.