小编Swa*_*pta的帖子

如何将参数传递给Thread中的ThreadStart方法?

如何将参数传递给Thread.ThreadStart()C#中的方法?

假设我有一个名为'download'的方法

public void download(string filename)
{
    // download code
}
Run Code Online (Sandbox Code Playgroud)

现在我在main方法中创建了一个线程:

Thread thread = new Thread(new ThreadStart(download(filename));
Run Code Online (Sandbox Code Playgroud)

错误方法类型预期.

如何ThreadStart使用参数将参数传递给目标方法?

.net c# multithreading

279
推荐指数
5
解决办法
35万
查看次数

如何将可选参数传递给C++中的方法?

如何将可选参数传递给C++中的方法?任何代码片段......

c++ optional-arguments

93
推荐指数
8
解决办法
12万
查看次数

如何在C#中将结构转换为字节数组?

如何在C#中将结构转换为字节数组?

我已经定义了这样的结构:

public struct CIFSPacket
{
    public uint protocolIdentifier; //The value must be "0xFF+'SMB'".
    public byte command;

    public byte errorClass;
    public byte reserved;
    public ushort error;

    public byte flags;

    //Here there are 14 bytes of data which is used differently among different dialects.
    //I do want the flags2. However, so I'll try parsing them.
    public ushort flags2;

    public ushort treeId;
    public ushort processId;
    public ushort userId;
    public ushort multiplexId;

    //Trans request
    public byte wordCount;//Count of parameter words defining the data …
Run Code Online (Sandbox Code Playgroud)

c# struct

72
推荐指数
6
解决办法
12万
查看次数

在C++中的Foreach循环相当于C#

我如何将此代码转换为C++?

string[] strarr = {"ram","mohan","sita"};    
foreach(string str in strarr) {
  listbox.items.add(str);
}
Run Code Online (Sandbox Code Playgroud)

c# c++

68
推荐指数
6
解决办法
12万
查看次数

如何在C#中使用FTP列出目录内容?

如何在C#中使用FTP列出目录内容?

我使用下面的代码用FTP列出目录内容它以XML格式返回结果,但我只想要目录的名称而不是整个内容.

我怎么能这样做?

public class WebRequestGetExample
{
    public static void Main ()
    {
        // Get the object used to communicate with the server.
        FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/");
        request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;

        // This example assumes the FTP site uses anonymous logon.
        request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");

        FtpWebResponse response = (FtpWebResponse)request.GetResponse();

        Stream responseStream = response.GetResponseStream();
        StreamReader reader = new StreamReader(responseStream);
        Console.WriteLine(reader.ReadToEnd());

        Console.WriteLine("Directory List Complete, status {0}", response.StatusDescription);

        reader.Close();
        response.Close();
    }
}
Run Code Online (Sandbox Code Playgroud)

MSDN

.net c# ftp directory-listing

42
推荐指数
1
解决办法
8万
查看次数

如何在C#中创建硬链接?

如何在C#中创建硬链接?请问任何代码片段?

.net c# hardlink

23
推荐指数
3
解决办法
1万
查看次数

C++中的套接字编程

任何人都可以使用C++中的套接字向我提供有关客户端和服务器连接的示例示例.我现在已经完成了一些教程,我想实现它.怎么开始?

c++ sockets networking network-programming

13
推荐指数
3
解决办法
6万
查看次数

如何从C#中的Given IP获取域名?

我想从给定的IP获取域名.例如,如果我将IP作为"172.24.17.85",我应该只获得像我的域名一样的域名是sonata.net.

C#中的任何代码片段?

c#

10
推荐指数
1
解决办法
2万
查看次数

如何将可选参数传递给C#中的方法?

如何将可选参数传递给C#中的方法?

假设我创建了一个名为Sendcommand的方法

public void SendCommand(String command,string strfilename)
{

    if (command == "NLST *" ) //Listing Files from Server.
    {
        //code
    }
    else if (command == "STOR " + Path.GetFileName(uploadfilename)) //Uploading file to Server
    {
        //code
    }
    else if ...
}
Run Code Online (Sandbox Code Playgroud)

现在我想在main方法中调用此方法

Sendcommand("STOR ", filename);
Sendcommand("LIST"); // In this case i dont want to pass the second parameter
Run Code Online (Sandbox Code Playgroud)

怎么实现呢?

.net optional-parameters c#-4.0

9
推荐指数
3
解决办法
4万
查看次数

如何检查目录是否已存在于MFC(VC++)中?

如何检查目录是否已存在于MFC(VC++)中?我使用下面的代码来获取当前的应用程序路径,并在那里我创建NDSLog文件夹,以便我所有的日志文件应该放在那里,现在我想检查条件,如果NDSLog文件夹已经存在不创建它.如何做到这一点?

谢谢.

char strPathName[_MAX_PATH];
    ::GetModuleFileName(NULL, strPathName, _MAX_PATH);

    // The following code will allow you to get the path.
    CString newPath(strPathName);
    int fpos = newPath.ReverseFind('\\');

    if (fpos != -1)
    newPath = newPath.Left(fpos+1);     
    newPath += "NDSLog\\" ;

    CreateDirectory(newPath,NULL); 
Run Code Online (Sandbox Code Playgroud)

mfc visual-c++

8
推荐指数
1
解决办法
3万
查看次数