警告访问process.start()的共享成员 [英] warning access of a shared member for process.start()
本文介绍了警告访问process.start()的共享成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我使用以下代码从文件夹中打开文件,当我使用process.start时,我收到了共享的警告访问权限成员,常量成员,通过实例的枚举成员,不会评估限定表达式,并且行 p.start(fname)以绿色下划线以绿色突出警告。
有人请帮忙删除这个,
提前致谢!!!
Hi All,
I use the below code to open a file from a folder and when i use process.start, i am getting a warning access of shared member,constant member, enum member through an instance, qualifying expression will not be evaluated and the line p.start(fname) gets zigzag underlined in green color throwing the warning.
Could someone please help to remove this,
Thanks in advance!!!
Imports System.IO
Imports System.Net
Imports System.Diagnostics.Process
Public Class _Default
Inherits System.Web.UI.Page
Dim path As String = ConfigurationManager.AppSettings("filepath")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not IsPostBack) Then
Dim di As DirectoryInfo = New DirectoryInfo(path)
Dim fidir As FileInfo() = di.GetFiles()
Dim fi As FileInfo
For Each fi In fidir
lstbx_file.Items.Add(fi.FullName)
Next
End If
End Sub
Protected Sub lstbx_file_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstbx_file.SelectedIndexChanged
Dim fname As String
Dim x As New _Default
fname = System.IO.Path.Combine(x.path, lstbx_file.SelectedValue.ToString())
Dim p As New Process()
p.Start(fname)
p.Close()
p.Dispose()
End Sub
End Class
推荐答案
不要这样做;
Do not do this;
Dim p As New Process()
p.Start(fname)
p.Close()
p.Dispose()
这样做,而不是;
Do, this instead;
Dim p As Process = Process.Start(fname)
p.WaitForExit() ' Might want to use a timeout here
p.Dispose()
希望这个帮助,
Fredrik
Hope this helps,
Fredrik
这篇关于警告访问process.start()的共享成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文