求高手,将这段c#代码,改写成vb.net的代码 ,急急急急 ,在线等
privatevoidSaveContents(stringhtml,stringurl){if(string.IsNullOrEmpty(html)){return;}...
private void SaveContents(string html, string url)
{
if (string.IsNullOrEmpty(html))
{
return;
}
string path = "";
lock (_locker)
{
path = string.Format("{0}\\{1}.txt", _path, _index++);
}
try
{
using (StreamWriter fs = new StreamWriter(path))
{
fs.Write(html);
}
}
catch (IOException ioe)
{
MessageBox.Show("SaveContents IO" + ioe.Message + " path=" + path);
}
if (ContentsSaved != null)
{
ContentsSaved(path, url);
}
} 展开
{
if (string.IsNullOrEmpty(html))
{
return;
}
string path = "";
lock (_locker)
{
path = string.Format("{0}\\{1}.txt", _path, _index++);
}
try
{
using (StreamWriter fs = new StreamWriter(path))
{
fs.Write(html);
}
}
catch (IOException ioe)
{
MessageBox.Show("SaveContents IO" + ioe.Message + " path=" + path);
}
if (ContentsSaved != null)
{
ContentsSaved(path, url);
}
} 展开
展开全部
Private Sub SaveContents(html As String, url As String)
If String.IsNullOrEmpty(html) Then
Return
End If
Dim path As String = ""
SyncLock _locker
path = String.Format("{0}\{1}.txt", _path, System.Math.Max(System.Threading.Interlocked.Increment(_index),_index - 1))
End SyncLock
Try
Using fs As New StreamWriter(path)
fs.Write(html)
End Using
Catch ioe As IOException
MessageBox.Show("SaveContents IO" + ioe.Message & " path=" & path)
End Try
RaiseEvent ContentsSaved(path, url)
End Sub
If String.IsNullOrEmpty(html) Then
Return
End If
Dim path As String = ""
SyncLock _locker
path = String.Format("{0}\{1}.txt", _path, System.Math.Max(System.Threading.Interlocked.Increment(_index),_index - 1))
End SyncLock
Try
Using fs As New StreamWriter(path)
fs.Write(html)
End Using
Catch ioe As IOException
MessageBox.Show("SaveContents IO" + ioe.Message & " path=" & path)
End Try
RaiseEvent ContentsSaved(path, url)
End Sub
追问
高手 ,我这句没看明白 System.Math.Max(System.Threading.Interlocked.Increment(_index), _index - 1)
追答
传回两个指定数字中较大的一个
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询