C# Silverlight文件上传,包括原始创建、修改和;访问日期

C# Silverlight文件上传,包括原始创建、修改和;访问日期,c#,file-upload,silverlight-5.0,C#,File Upload,Silverlight 5.0,我用这些方法上传文件 客户端: private void Add(object sender, MouseButtonEventArgs e) { OpenFileDialog OFD = new OpenFileDialog(); OFD.Multiselect = true; OFD.Filter = "Python (*.py)|*.py"; bool? Result = OFD.ShowDialog();

我用这些方法上传文件

客户端:

    private void Add(object sender, MouseButtonEventArgs e)
    {
        OpenFileDialog OFD = new OpenFileDialog();
        OFD.Multiselect = true;
        OFD.Filter = "Python (*.py)|*.py";
        bool? Result = OFD.ShowDialog();
        if (Result != null && Result == true)
            foreach (var File in OFD.Files)
                mylistbox.Items.Add(File);
    }
    private void Submit(object sender, MouseButtonEventArgs e)
    {
        foreach (var File in mylistbox.Items)
            Process(((FileInfo)File).Name.Replace(((FileInfo)File).Extension, string.Empty), ((FileInfo)File).OpenRead());
    }
    private void Process(string File, Stream Data)
    {
        UriBuilder Endpoint = new UriBuilder("http://localhost:5180/Endpoint.ashx");
        Endpoint.Query = string.Format("File={0}", File);

        WebClient Client = new WebClient();
        Client.OpenWriteCompleted += (sender, e) =>
        {
            Send(Data, e.Result);
            e.Result.Close();
            Data.Close();
        };
        Client.OpenWriteAsync(Endpoint.Uri);
    }
    private void Send(Stream Input, Stream Output)
    {
        byte[] Buffer = new byte[4096];
        int Flag;

        while ((Flag = Input.Read(Buffer, 0, Buffer.Length)) != 0)
        {
            Output.Write(Buffer, 0, Flag);
        }
    }
服务器端:

    public void ProcessRequest(HttpContext Context)
    {
        using (FileStream Stream = File.Create(Context.Server.MapPath("~/" + Context.Request.QueryString["File"].ToString() + ".py")))
        {
            Save(Context.Request.InputStream, Stream);
        }
    }

    private void Save(Stream Input, FileStream Output)
    {
        byte[] Buffer = new byte[4096];
        int Flag;
        while ((Flag = Input.Read(Buffer, 0, Buffer.Length)) != 0)
        {
            Output.Write(Buffer, 0, Flag);
        }
    }
我的问题是上传的文件有不同的创建、修改和访问日期
为什么?

上载文件时,实际上是在创建一个包含重复内容的新文件

从您的代码:

using (FileStream Stream = File.Create(Context.Server.MapPath("~/" + Context.Request.QueryString["File"].ToString() + ".py")))
{
    Save(Context.Request.InputStream, Stream);
}
文件.Create
负责新日期


有关保存日期的信息,请参见此部分。

您能举一个日期示例吗?与上载的原始文件不同吗?原始日期将替换为今天的日期。这是因为您正在创建一个新文件。我以为你的意思是新文件的创建日期与新文件的修改日期不同。上载文件时,实际上是在创建一个包含重复内容的新文件。“但是,此解决方案目前仅适用于图像文件”