vb.net 中的 MemoryStream 中的空路径名不合法
Empty path name is not legal in MemoryStream in vb.net
如果出现错误“空路径名不合法”的解决方案是什么,因为在数据库中列 Filename6 是空的,如果在图像文件夹中找不到 filename1 到 filename6 之间的字段,解决方案是什么.
谢谢
杰克
Private Sub GridView1_RowCellClick(sender As Object, e As RowCellClickEventArgs) Handles GridView1.RowCellClick
Dim view As GridView = TryCast(sender, GridView)
Dim SUBFOLDERP As String = view.GetFocusedRowCellValue("SUBFOLDERP").ToString
Dim Filename1 As String = view.GetFocusedRowCellValue("Filename1").ToString
Dim Filename2 As String = view.GetFocusedRowCellValue("Filename2").ToString
Dim Filename3 As String = view.GetFocusedRowCellValue("Filename3").ToString
Dim Filename4 As String = view.GetFocusedRowCellValue("Filename4").ToString
Dim Filename5 As String = view.GetFocusedRowCellValue("Filename5").ToString
Dim Filename6 As String = view.GetFocusedRowCellValue("Filename6").ToString
If e.Column.FieldName = "Code" Then
Dim Code As String = view.GetRowCellValue(e.RowHandle, e.Column).ToString
Dim filePath1 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename1, False)
Dim filePath2 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename2, False)
Dim filePath3 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename3, False)
Dim filePath4 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename4, False)
Dim filePath5 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename5, False)
Dim filePath6 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename6, False)
PictureEdit1.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath1)), True, False)
PictureEdit2.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath2)), True, False)
PictureEdit3.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath3)), True, False)
PictureEdit4.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath4)), True, False)
PictureEdit5.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath5)), True, False)
PictureEdit6.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath6)), True, False) 'error this line code
End If
End Sub
Private Sub GridView1_RowCellClick(sender As Object, e As RowCellClickEventArgs) Handles GridView1.RowCellClick
Dim view As GridView = TryCast(sender, GridView)
Dim SUBFOLDERP As String = view.GetFocusedRowCellValue("SUBFOLDERP").ToString
Dim Filename1 As String = view.GetFocusedRowCellValue("Filename1").ToString
Dim Filename2 As String = view.GetFocusedRowCellValue("Filename2").ToString
Dim Filename3 As String = view.GetFocusedRowCellValue("Filename3").ToString
Dim Filename4 As String = view.GetFocusedRowCellValue("Filename4").ToString
Dim Filename5 As String = view.GetFocusedRowCellValue("Filename5").ToString
Dim Filename6 As String = view.GetFocusedRowCellValue("Filename6").ToString
If e.Column.FieldName = "Code" Then
Dim Code As String = view.GetRowCellValue(e.RowHandle, e.Column).ToString
Dim filePath1 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename1, False)
Dim filePath2 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename2, False)
Dim filePath3 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename3, False)
Dim filePath4 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename4, False)
Dim filePath5 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename5, False)
Dim filePath6 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename6, False)
PictureEdit1.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath1)), True, False)
PictureEdit2.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath2)), True, False)
PictureEdit3.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath3)), True, False)
PictureEdit4.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath4)), True, False)
PictureEdit5.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath5)), True, False)
**If Not String.IsNullOrWhiteSpace(filePath6) Then**
PictureEdit6.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath6)), True, False)
**End If**
End If
End Sub
如果出现错误“空路径名不合法”的解决方案是什么,因为在数据库中列 Filename6 是空的,如果在图像文件夹中找不到 filename1 到 filename6 之间的字段,解决方案是什么.
谢谢 杰克
Private Sub GridView1_RowCellClick(sender As Object, e As RowCellClickEventArgs) Handles GridView1.RowCellClick
Dim view As GridView = TryCast(sender, GridView)
Dim SUBFOLDERP As String = view.GetFocusedRowCellValue("SUBFOLDERP").ToString
Dim Filename1 As String = view.GetFocusedRowCellValue("Filename1").ToString
Dim Filename2 As String = view.GetFocusedRowCellValue("Filename2").ToString
Dim Filename3 As String = view.GetFocusedRowCellValue("Filename3").ToString
Dim Filename4 As String = view.GetFocusedRowCellValue("Filename4").ToString
Dim Filename5 As String = view.GetFocusedRowCellValue("Filename5").ToString
Dim Filename6 As String = view.GetFocusedRowCellValue("Filename6").ToString
If e.Column.FieldName = "Code" Then
Dim Code As String = view.GetRowCellValue(e.RowHandle, e.Column).ToString
Dim filePath1 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename1, False)
Dim filePath2 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename2, False)
Dim filePath3 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename3, False)
Dim filePath4 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename4, False)
Dim filePath5 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename5, False)
Dim filePath6 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename6, False)
PictureEdit1.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath1)), True, False)
PictureEdit2.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath2)), True, False)
PictureEdit3.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath3)), True, False)
PictureEdit4.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath4)), True, False)
PictureEdit5.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath5)), True, False)
PictureEdit6.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath6)), True, False) 'error this line code
End If
End Sub
Private Sub GridView1_RowCellClick(sender As Object, e As RowCellClickEventArgs) Handles GridView1.RowCellClick
Dim view As GridView = TryCast(sender, GridView)
Dim SUBFOLDERP As String = view.GetFocusedRowCellValue("SUBFOLDERP").ToString
Dim Filename1 As String = view.GetFocusedRowCellValue("Filename1").ToString
Dim Filename2 As String = view.GetFocusedRowCellValue("Filename2").ToString
Dim Filename3 As String = view.GetFocusedRowCellValue("Filename3").ToString
Dim Filename4 As String = view.GetFocusedRowCellValue("Filename4").ToString
Dim Filename5 As String = view.GetFocusedRowCellValue("Filename5").ToString
Dim Filename6 As String = view.GetFocusedRowCellValue("Filename6").ToString
If e.Column.FieldName = "Code" Then
Dim Code As String = view.GetRowCellValue(e.RowHandle, e.Column).ToString
Dim filePath1 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename1, False)
Dim filePath2 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename2, False)
Dim filePath3 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename3, False)
Dim filePath4 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename4, False)
Dim filePath5 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename5, False)
Dim filePath6 As String = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename6, False)
PictureEdit1.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath1)), True, False)
PictureEdit2.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath2)), True, False)
PictureEdit3.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath3)), True, False)
PictureEdit4.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath4)), True, False)
PictureEdit5.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath5)), True, False)
**If Not String.IsNullOrWhiteSpace(filePath6) Then**
PictureEdit6.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath6)), True, False)
**End If**
End If
End Sub