0

I have a Windows Form Application that loads up a datagridview. In one of the columns is hyperlinks to image files. When these links are clicked my code shown below runs to open up the image. However, I have a new user on the system that has issues viewing any of the images.

At first it was found that the user did not have access to one of the subfolders in the image path. After this was corrected, the user can now access the full image path and view images through the windows explorer.

However, when running the application and clicking the hyperlinks, my user is receiving:

Error: Access to the path '\\Server\folder1\folder2\folder3\image.tif' is denied. In Procedure: FQImagingFilteredDataGridView_CellClick

Any ideas for what is going on? The user has full rights to the directory, even individual rights, and can now successfully view the images through windows explorer, but the application still treats the user as denied.

Here is my code:

Private Sub FQImagingFilteredDataGridView_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles FQImagingFilteredDataGridView.CellClick
    Try
        If e.RowIndex = -1 Then Exit Sub
        If e.ColumnIndex <> 0 Then Exit Sub
        Dim ImageFile As String = FQImagingFilteredDataGridView.CurrentRow.Cells("FILEPATH").Value.ToString & "\" & FQImagingFilteredDataGridView.CurrentRow.Cells("FILENAME").Value.ToString

        If Not IO.File.Exists(ImageFile) Then
            MsgBox("Image file not found - unable to display!", MsgBoxStyle.Information, "Attention!")
            Exit Sub
        End If

        ' Pass a memory stream version of image to ImageForm
        Dim DisplayImage As Image = LoadMemoryImage(ImageFile)
        If Not IsNothing(DisplayImage) Then
            Using ImageDisplayForm As New ImageForm(DisplayImage, ImageFile, True)
                With ImageDisplayForm
                    .Text = ImageFile.Substring(InStrRev(ImageFile, "\"))
                    .ShowDialog()
                End With
            End Using
        End If

    Catch ex As Exception
        MsgBox("Error: " + ex.Message + "  In Procedure:  " + Miscellaneous.InvokedBy(), MsgBoxStyle.Information, Me.Text)
    End Try
End Sub

Any assistance appreciated.

karthikr
  • 97,368
  • 26
  • 197
  • 188
Analytic Lunatic
  • 3,853
  • 22
  • 78
  • 120
  • 2
    So which line throws the exception? What specific type of exception is it? Showing the stack trace may be helpful. A friendly pointer, when displaying an exception, often the best option is to display `ex.ToString` since that includes the exception type, message, stack trace, and inner exceptions. – Steven Doggart Sep 24 '13 at 15:53
  • As an aside, instead of using Substring and InStrRev to get your filename, just use the methods in the Path class. In this case you can use `Path.GetFilename(ImageFile)`. This makes your code more readable and maintainable. – Chris Dunaway Sep 24 '13 at 17:49
  • Thanks for the input. This is an application that got thrown my was when it error'd, I've never had any dealings with it before (not my coding style). As for the stack trace and everything, I do not know at this point. The issue is occurring only for this one new user. – Analytic Lunatic Sep 24 '13 at 21:14

0 Answers0