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);
}
} 展开
1个回答
展开全部
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询