none
C# Winform upload file questions RRS feed

  • Question

  • I  could upload file to our site every mins, so I want to know how I could know which file has beed uploaded and which has not beed uploaded. How to judge it, please share me a solution.

    this is my own solution:

    I could use linq to query all files' write time, and save the previous upload time, then when I upload file next, I will query all files' write time that beyond than the previous time.

    But there is a bug in my solution , if upload process has been interrupted, so how to do next? I could not get previous upload time.

    Please share me a good solution for this situation. Thank you very much. :)

    Friday, March 2, 2018 3:04 AM

All replies

  • Hi,

    I'm not sure how do you upload your file to the site, but I think it is similar to save some records to a database, in the latter scenario, we can use SQL statements to determine whether the target already exists, if not, then insert:

            private void button1_Click(object sender, EventArgs e)
            {
                string strConn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Files\Database1.accdb";
                using (OleDbConnection conn = new OleDbConnection(strConn))
                {
                    conn.Open();
                    string select = "select * from T_Users where UserName='" + textBox1.Text + "'";
                    using (OleDbCommand cmd = new OleDbCommand(select, conn))
                    {
                        int count = Convert.ToInt32(cmd.ExecuteScalar());
                        if (count > 0)
                        {
                            MessageBox.Show("Existed!");
                        }
                        else
                        {
                            cmd.CommandText = "insert into T_Users(UserName,Age) values('" + textBox1.Text + "',30)";
                            cmd.ExecuteNonQuery();
                            MessageBox.Show("Inserted!");
                        }
                    }
                }
            }

    Maybe you can refer to this case to achieve your purpose.

    Regards,

    Frankie


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 5, 2018 6:42 AM
    Moderator
  • you are wrong
    Thursday, March 8, 2018 1:46 AM
  • Hi qing_,

    >>I  could upload file to our site every mins,

    How did you upload the file  to your site? Can you share your code here?

    Best  Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 8, 2018 6:48 AM
  • you could use webclient and httprequest.
    Monday, March 26, 2018 5:48 AM
  • anyone else?
    Tuesday, April 17, 2018 3:00 AM