这一切都是在一小时前和很多天前完成的.我尝试ping的链接是:
这是form1中的代码:
nc = new NetworkConnection();
bool bval = nc.PingConnection(satellite_address);
if (bval)
{
label19.Visible = true;
label19.Text = "Internet Access";
}
else
{
label19.Visible = true;
label19.Text = "No Internet Access";
}
Run Code Online (Sandbox Code Playgroud)
当它试图执行此行时:
bool bval = nc.PingConnection(satellite_address);
Run Code Online (Sandbox Code Playgroud)
它会nc上课:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.NetworkInformation;
using System.IO;
using System.Windows.Forms;
namespace mws
{
class NetworkConnection
{
public NetworkConnection()
{
}
public bool PingConnection(string url)
{
bool Result = false;
using (Ping pp = …Run Code Online (Sandbox Code Playgroud) Directory.CreateDirectory(@"c:\temp\newimages\" + "SecondProcess_" +
DateTime.Now);
Run Code Online (Sandbox Code Playgroud)
我想要创建的是c:\ temp \newimages \中的目录.例如:
C:\ TEMP \newimages\SecondProcess_5/13/2014-2:33
NotsupportedException:不支持给定路径的格式
System.NotSupportedException was unhandled
HResult=-2146233067
Message=The given path's format is not supported.
Source=mscorlib
StackTrace:
at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
at System.IO.Directory.CreateDirectory(String path)
at mws.Animation_Radar_Preview.numericUpDown1_ValueChanged(Object sender, EventArgs e) in d:\C-Sharp\Download File\Downloading-File-Project-Version-012\Downloading File\Animation_Radar_Preview.cs:line 457
at System.Windows.Forms.NumericUpDown.OnValueChanged(EventArgs e)
at …Run Code Online (Sandbox Code Playgroud)