Esempio n. 1
0
        private void ServerPressureTest(object obj)
        {
            if (obj is string path)
            {
                string pathNew = System.IO.Path.Combine(Application.StartupPath, path);
                System.IO.Directory.CreateDirectory(pathNew);
                for (int j = 0; j < 100; j++)
                {
                    string fileName = path + "-A" + random.Next(500) + ".txt";
                    string fullName = System.IO.Path.Combine(pathNew, fileName);

                    StringBuilder sb = new StringBuilder( );
                    for (int i = 0; i < 1024; i++)
                    {
                        sb.Append('1');
                    }
                    System.IO.File.WriteAllText(fullName, sb.ToString( ), Encoding.UTF8);
                    if (integrationFileClient.UploadFile(fullName, "Files", "Group", "id", null).IsSuccess)
                    {
                        upSuccess++;
                    }
                    System.IO.File.Delete(fullName);
                    if (!integrationFileClient.IsFileExists(fileName, "Files", "Group", "id").Content)
                    {
                        upSuccess--;
                        continue;
                    }

                    if (integrationFileClient.DownloadFile(fileName, "Files", "Group", "id", null, fullName).IsSuccess)
                    {
                        downSuccess++;
                    }
                    System.IO.File.Delete(fullName);


                    if (integrationFileClient.DeleteFile(fileName, "Files", "Group", "id").IsSuccess)
                    {
                        deleteSuccess++;
                    }
                    if (integrationFileClient.IsFileExists(fileName, "Files", "Group", "id").Content)
                    {
                        deleteSuccess--;
                        continue;
                    }
                }
                System.IO.Directory.Delete(pathNew);
                if (System.Threading.Interlocked.Decrement(ref threadlength) == 0)
                {
                    Invoke(new Action(() =>
                    {
                        button7.Enabled = true;
                        MessageBox.Show("成功上传次数:" + upSuccess + Environment.NewLine + "成功下载次数:" + downSuccess + Environment.NewLine + "成功删除次数:" + deleteSuccess);
                    }));
                }
            }
        }
Esempio n. 2
0
        private void button5_Click(object sender, EventArgs e)
        {
            // 文件的删除不需要放在后台线程,前台即可处理,无论多少大的文件,无论该文件是否在下载中,都是很快删除的
            OperateResult result = integrationFileClient.DeleteFile("123.txt", "Files", "Personal", "Admin");

            if (result.IsSuccess)
            {
                MessageBox.Show("文件删除成功!");
            }
            else
            {
                // 删除失败的原因除了一般的网络问题,还有因为服务器的文件不存在,会在Message里有显示。
                MessageBox.Show("文件删除失败,原因:" + result.ToMessageShowString( ));
            }
        }
        private void button5_Click(object sender, EventArgs e)
        {
            // 文件的删除不需要放在后台线程,前台即可处理,无论多少大的文件,无论该文件是否在下载中,都是很快删除的
            OperateResult result = integrationFileClient.DeleteFile(
                textBox_delete_fileName.Text,                       // 文件在服务器上保存的名称,举例123.txt
                textBox_delete_factory.Text,                        // 第一级分类,指示文件存储的类别,对应在服务器端存储的路径不一致
                textBox_delete_id.Text,                             // 第二级分类,指示文件存储的类别,对应在服务器端存储的路径不一致
                textBox_download_id.Text                            // 第三级分类,指示文件存储的类别,对应在服务器端存储的路径不一致
                );

            if (result.IsSuccess)
            {
                // delete file success
                MessageBox.Show("文件删除成功!");
            }
            else
            {
                // 删除失败的原因除了一般的网络问题,还有因为服务器的文件不存在,会在Message里有显示。
                // file not exsist or net work exception
                MessageBox.Show("文件删除失败,原因:" + result.ToMessageShowString( ));
            }
        }