Exemplo n.º 1
0
    private void ListUploadedFiles()
    {
        CheckBoxListUploadedFile.Items.Clear();
        TheAdminServer.ListUploadedFiles(out fileInfos);
        long totleFileLength = 0;

        if (fileInfos != null && fileInfos.Length > 0)
        {
            LabelUploadedNoFile.Visible = false;
            foreach (FileInfo file in fileInfos)
            {
                totleFileLength += file.Length;
                CheckBoxListUploadedFile.Items.Add(new ListItem(file.Name, file.FullName));
            }
        }
        else
        {
            LabelUploadedNoFile.Visible = true;
        }
        string totleFileLengthText = string.Empty;

        if (totleFileLength < 1024)
        {
            totleFileLengthText = Decimal.Round((decimal)totleFileLength, 2).ToString() + "B";
        }
        else if (totleFileLength < 1024 * 1024)
        {
            totleFileLengthText = Decimal.Round((decimal)totleFileLength / (decimal)1024, 2).ToString() + "K";
        }
        else
        {
            totleFileLengthText = Decimal.Round(totleFileLength / (decimal)1024 / (decimal)1024, 2) + "M";
        }
        LabelUploadedFilesInfo.Text = String.Format(StringDef.UploadFileDirSummary, fileInfos.Length, totleFileLengthText);
    }
Exemplo n.º 2
0
    private void ListUploadedFiles()
    {
        CheckBoxListUploadedFile.Items.Clear();
        FileInfo[] fileInfos;
        TheAdminServer.ListUploadedFiles(out fileInfos);
        long totleFileLength = 0;

        if (fileInfos != null && fileInfos.Length > 0)
        {
            LabelUploadedNoFile.Visible = false;
            foreach (FileInfo fi in fileInfos)
            {
                fi.Refresh();

                totleFileLength += fi.Length;
                StringBuilder fileInfoText = new StringBuilder();

                fileInfoText.Append(fi.Name);
                fileInfoText.Append(" ");

                fileInfoText.AppendFormat("[{0}]", WebUtil.BetterSizeText(fi.Length));
                fileInfoText.AppendFormat(" [{0}] ", fi.LastWriteTime);

                fileInfoText.Append(string.Format("[<a href = 'GameServerHandler.ashx?{0}={1}&{2}={3}' target='_blank'>", WebConfig.ParamOperation, "GetFSEyeFile", WebConfig.ParamFileName, Convert.ToBase64String(Encoding.Default.GetBytes(fi.Name))) + StringDef.Download + "</a>]");

                CheckBoxListUploadedFile.Items.Add(new ListItem(fileInfoText.ToString(), fi.Name));
            }
        }
        else
        {
            LabelUploadedNoFile.Visible = true;
        }

        string totleFileLengthText = WebUtil.BetterSizeText(totleFileLength);

        LabelUploadedFilesInfo.Text = String.Format(StringDef.UploadFileDirSummary, fileInfos.Length, totleFileLengthText);
    }