Пример #1
0
        public void StartNew(WinFileSystem win, ClientInfo client, FileFolderInfo selectedFile)
        {
            ControlledClient = client;
            string path = FileSystemDialog.GetSaveFile(null, true, false, selectedFile.Name);

            if (path != null)
            {
                FileTransmissionInfo trans = new FileTransmissionInfo()
                {
                    File = selectedFile
                };
                try
                {
                    download = new DownloadingInfo(win, client, path, trans);
                }
                catch (Exception ex)
                {
                    TaskDialog.ShowException(ex, "建立本地文件失败!");
                    return;
                }
                Telnet.Instance.FileSystemDownloadErrorReceived += FileSystemDownloadErrorReceived;
                Telnet.Instance.FileSystemDownloadPartReceived  += FileSystemDownloadPartReceived;

                Telnet.Instance.Send(new CommandBody(
                                         File_AskForDownloading, Global.CurrentClient.ID, client.ID, trans));

                download.Dialog.ShowDialog();
            }
        }
 public void GetFileInfo(DirectoryInfo DirectoryInfo, ref FileFolderInfo items)
 {
     if (!SelectedFilter.Contains("*.*"))
     {
         foreach (System.IO.FileInfo directoryinfo in DirectoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).Where(s => SelectedFilter.Split('|')[1].Contains(s.Extension.ToLower())).Where(s => !AvoidedFilePaths.Contains(s.FullName)))
         {
             if ((directoryinfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden && directoryinfo.Extension != "")
             {
                 items.FileFolders.Add(new FileFolderInfo
                 {
                     Name         = directoryinfo.Name,
                     Path         = directoryinfo.FullName,
                     DateModified = directoryinfo.LastWriteTime,
                     IsFile       = true
                 });
             }
         }
     }
     else
     {
         foreach (System.IO.FileInfo directoryinfo in DirectoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).Where(s => !AvoidedFilePaths.Contains(s.FullName)))
         {
             if ((directoryinfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden && directoryinfo.Extension != "")
             {
                 items.FileFolders.Add(new FileFolderInfo
                 {
                     Name         = directoryinfo.Name,
                     Path         = directoryinfo.FullName,
                     DateModified = directoryinfo.LastWriteTime,
                     IsFile       = true
                 });
             }
         }
     }
 }
        public static async Task <FileFolderInfo> CreateFolder(UserTokenHandler tokenHandler, string name, string parentFolderID, string description)
        {
            var            client     = GetNewBoxClient(tokenHandler);
            FileFolderInfo folderInfo = await CreateFolder(client, tokenHandler, name, parentFolderID).ConfigureAwait(false);

            UpdateFolderDescription(client, tokenHandler, folderInfo.ID, description).Wait();

            return(new FileFolderInfo
            {
                ID = folderInfo.ID,
                Name = folderInfo.Name,
                ParentFolderID = folderInfo.ParentFolderID,
                ModifiedAt = folderInfo.ModifiedAt
            });
        }
 public void GetDirectoryData(DirectoryInfo DirectoryInfo, ref FileFolderInfo folder)
 {
     foreach (DirectoryInfo directoryinfo in DirectoryInfo.GetDirectories("*.*", SearchOption.TopDirectoryOnly).Where(s => !AvoidedFilePaths.Contains(s.FullName)))
     {
         if ((directoryinfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
         {
             folder.FileFolders.Add(new FileFolderInfo
             {
                 Name         = directoryinfo.Name,
                 Path         = directoryinfo.FullName,
                 IsDirectory  = true,
                 DateModified = directoryinfo.LastWriteTime
                                //Files= GetFileInfo(directoryinfo),
                                //Folders=GetDirectoryData(directoryinfo)
             });
         }
     }
 }
 public void loadTreeData()
 {
     Drives = new ObservableCollection <FileFolderInfo>();
     foreach (DriveInfo info in DriveInfo.GetDrives())
     {
         if (!AvoidedFilePaths.Split(',').Contains(info.RootDirectory.FullName))
         {
             if (info.IsReady)
             {
                 FileFolderInfo harddriveinfo = new FileFolderInfo();
                 harddriveinfo.FileFolders = new ObservableCollection <FileFolderInfo>();
                 GetDirectoryData(info.RootDirectory, ref harddriveinfo);
                 GetFileInfo(info.RootDirectory, ref harddriveinfo);
                 harddriveinfo.IsDrive = true;
                 harddriveinfo.Name    = info.Name;
                 harddriveinfo.Path    = info.RootDirectory.FullName;
                 Drives.Add(harddriveinfo);
             }
         }
     }
 }
Пример #6
0
        public List <FileFolderInfo> GetDirectories(string p_folderPath)
        {
            HttpServerUtility     server         = HttpContext.Current.Server;
            string                sortExpression = HttpContext.Current.Request.QueryString["order"];
            List <FileFolderInfo> list           = new List <FileFolderInfo>();
            DirectoryInfo         info3          = new DirectoryInfo(p_folderPath);

            try
            {
                foreach (FileSystemInfo info4 in info3.GetFileSystemInfos())
                {
                    string str2;
                    if (string.IsNullOrEmpty(this._FolderPath))
                    {
                        this._FolderPath = HttpContext.Current.Request.PhysicalApplicationPath + "Files";
                    }

                    if (info4 is DirectoryInfo)
                    {
                        DirectoryInfo info = info4 as DirectoryInfo;
                        if (Utils.Isie())
                        {
                            str2 = "<a href=\"" + Utils.getUrl("filemanager.aspx?path=" + server.UrlEncode(info.FullName) + "") + "\"><img src=\"/Files/sys/IcoFolder.gif\" alt=\"文件夹\" /> " + info.Name + "</a>";
                        }
                        else
                        {
                            str2 = "<a href=\"" + Utils.getUrl("filemanager.aspx?path=" + server.UrlEncode(info.FullName) + "") + "\"> " + info.Name + "</a>";
                        }

                        string compic = "";
                        if (Utils.Isie())
                        {
                            compic = "<img src=\"/Files/sys/IcoPackage.gif\" alt=\"压缩\" />";
                        }
                        else
                        {
                            compic = "[压缩]";
                        }

                        str2 += " <a href=\"" + Utils.getUrl("filemanager.aspx?act=compress&amp;path=" + server.UrlEncode(this._FolderPath) + "&amp;objfolder=" + server.UrlEncode(info.FullName) + "") + "\">" + compic + "</a>";

                        FileFolderInfo info5 = new FileFolderInfo();
                        info5.Name       = info.Name;
                        info5.FullName   = server.UrlEncode(info.FullName);
                        info5.FormatName = str2;
                        info5.Ext        = "";
                        info5.Size       = "0";
                        info5.Type       = "folder";
                        info5.ModifyDate = info.LastWriteTime;
                        list.Add(info5);
                        this._FolderNum++;
                    }
                    else
                    {
                        FileInfo info2 = info4 as FileInfo;
                        // str2 = "<a href=\"file.axd?file=" + server.UrlEncode(info2.FullName) + "\" target=\"_new\"><img src=\"/Files/sys/IcoOtherFile.gif\" alt=\"文件\" /> " + info2.Name + "</a>";
                        if (Utils.Isie())
                        {
                            str2 = "<img src=\"/Files/sys/IcoOtherFile.gif\" alt=\"文件\"/>" + info2.Name + "";
                        }
                        else
                        {
                            str2 = "" + info2.Name + "";
                        }

                        if (info2.Extension.ToLower() == ".zip")
                        {
                            string str3 = str2;
                            if (Utils.Isie())
                            {
                                str2 = str3 + "<a href=\"" + Utils.getUrl("filemanager.aspx?act=unpack&amp;path=" + server.UrlEncode(this._FolderPath) + "&amp;objfile=" + server.UrlEncode(info2.FullName) + "") + "\"><img src=\"/Files/sys/IcoZip.gif\" alt=\"解压\" /></a>";
                            }
                            else
                            {
                                str2 = str3 + "<a href=\"" + Utils.getUrl("filemanager.aspx?act=unpack&amp;path=" + server.UrlEncode(this._FolderPath) + "&amp;objfile=" + server.UrlEncode(info2.FullName) + "") + "\">[解压]</a>";
                            }
                        }
                        else if ((info2.Length < 0xc350L) && this.CheckExtHighlighter(info2.Extension.ToLower()))
                        {
                            if (Utils.Isie())
                            {
                                str2 = str2 + "<a href=\"" + Utils.getUrl("filemanager.aspx?info=text&amp;path=" + server.UrlEncode(this._FolderPath) + "&amp;objfile=" + server.UrlEncode(info2.FullName) + "") + "\"><img src=\"/Files/sys/IcoNotepad.gif\" alt=\"编辑\" /></a>";
                            }
                            else
                            {
                                str2 = str2 + "<a href=\"" + Utils.getUrl("filemanager.aspx?info=text&amp;path=" + server.UrlEncode(this._FolderPath) + "&amp;objfile=" + server.UrlEncode(info2.FullName) + "") + "\">[编辑]</a>";
                            }

                            // if (this.CheckExtHighlighter(info2.Extension.ToLower()))
                            //{
                            ////取虚拟路径
                            //string rootPath = server.MapPath("/");
                            //string FullName = info2.FullName.Remove(0, rootPath.Length);
                            //if (Utils.Isie())
                            //    str2 = str2 + "<a href=\"/" + FullName + "\"><img src=\"/Files/sys/IcoHighlighter.gif\" alt=\"访问\" /></a>";
                            //else
                            //    str2 = str2 + "<a href=\"/" + FullName + "\">[访问]</a>";

                            //}
                        }

                        //取虚拟路径
                        string rootPath = server.MapPath("/");
                        string FullName = info2.FullName.Remove(0, rootPath.Length);
                        if (Utils.Isie())
                        {
                            str2 = str2 + "<a href=\"/" + FullName + "\"><img src=\"/Files/sys/IcoHighlighter.gif\" alt=\"访问\" /></a>";
                        }
                        else
                        {
                            str2 = str2 + "<a href=\"/" + FullName + "\">[访问]</a>";
                        }

                        FileFolderInfo info6 = new FileFolderInfo();
                        info6.Name       = info2.Name;
                        info6.FullName   = server.UrlEncode(info2.FullName);
                        info6.FormatName = str2;
                        info6.Ext        = info2.Extension;
                        info6.Size       = info2.Length.ToString();
                        info6.Type       = "file";
                        info6.ModifyDate = info2.LastWriteTime;
                        list.Add(info6);
                        this._FileNum++;
                    }
                }
                this._Access = true;
            }
            catch
            {
                this._Access = false;
                return(list);
            }
            if (!string.IsNullOrEmpty(sortExpression))
            {
                list.Sort(new FilesComparer(sortExpression));
            }
            return(list);
        }
        /// <summary>
        /// 取得目录下所有文件
        /// </summary>
        /// <param name="p_folderPath">目录路径</param>
        /// <param name="p_read">是否操作成功</param>
        /// <returns>List FileInfo</returns>
        public List <FileFolderInfo> GetDirectories(string p_folderPath)
        {
            HttpServerUtility Server  = HttpContext.Current.Server;
            HttpRequest       Request = HttpContext.Current.Request;

            string order = Request.QueryString["order"];
            string urlString;
            List <FileFolderInfo> files = new List <FileFolderInfo>();
            DirectoryInfo         di;
            FileInfo fi;

            DirectoryInfo dir = new DirectoryInfo(Server.MapPath(p_folderPath == string.Empty ? "/" : p_folderPath));

            try
            {
                foreach (FileSystemInfo fsi in dir.GetFileSystemInfos())
                {
                    if (fsi is DirectoryInfo)
                    {
                        di        = fsi as DirectoryInfo;
                        urlString = "<a href=\"Main.aspx?path=" + Server.UrlEncode(PagePath2(di.FullName)) + "\">" +
                                    "<img src=\"../Images/IcoFolder.gif\" alt=\"文件夹\" align=\"absmiddle\" /> " + di.Name + "</a>" +
                                    " <a href=\"Main.aspx?act=compress&amp;path=" + Server.UrlEncode(PagePath2(this._FolderPath)) + "&amp;objfolder=" + Server.UrlEncode(PagePath2(di.FullName)) + "\" onclick=\"javascript:compressMsg();\">" +
                                    "<img src=\"../Images/IcoPackage.gif\" alt=\"压缩\" align=\"absmiddle\" /></a>";

                        FileFolderInfo objFolder = new FileFolderInfo(di.Name, Server.UrlEncode(di.FullName), urlString, "", 0, "folder", di.LastWriteTime);
                        files.Add(objFolder);

                        this._FolderNum++;
                    }
                    else
                    {
                        fi = fsi as FileInfo;

                        urlString = "<a href=\"file.axd?file=" + Server.UrlEncode(fi.FullName) + "\" target=\"_new\">" +
                                    "<img src=\"../Images/IcoOtherFile.gif\" alt=\"文件\" align=\"absmiddle\" /> " + fi.Name + "</a>";

                        if (fi.Extension.ToLower() == ".zip")
                        {
                            urlString += "&nbsp;<a href=\"Main.aspx?act=unpack&amp;path=" + Server.UrlEncode(PagePath2(this._FolderPath)) + "&amp;objfile=" + Server.UrlEncode(PagePath2(fi.FullName)) + "\" onclick=\"javascript:unpackMsg();\">" +
                                         "<img src=\"../Images/IcoZip.gif\" alt=\"解压\" align=\"absmiddle\" /></a>";
                        }
                        else if (CheckExtEdit(fi.Extension.ToLower()))
                        {
                            urlString += "&nbsp;<a class=\"submodal-700-400\" href=\"Notepad.aspx?objfile=" + Server.UrlEncode(fi.FullName) + "\">" +
                                         "<img src=\"../Images/IcoNotepad.gif\" alt=\"编辑\" align=\"absmiddle\" /></a>";

                            if (CheckExtHighlighter(fi.Extension.ToLower()))
                            {
                                urlString += "&nbsp;<a href=\"ViewCode.aspx?objfile=" + Server.UrlEncode(fi.FullName) + "\" target=\"_new\"><img src=\"../Images/IcoHighlighter.gif\" alt=\"查看代码\" align=\"absmiddle\" /></a>";
                            }
                        }

                        FileFolderInfo objFile = new FileFolderInfo(fi.Name, Server.UrlEncode(fi.FullName), urlString, fi.Extension, fi.Length, "file", fi.LastWriteTime);
                        files.Add(objFile);

                        this._FileNum++;
                    }
                }
                this._Access = true;
            }
            catch
            {
                this._Access = false;
                return(files);
            }

            if (!string.IsNullOrEmpty(order))
            {
                files.Sort(new FilesComparer(order));
            }

            return(files);
        }
Пример #8
0
        public List <FileFolderInfo> GetDirectories(string p_folderPath)
        {
            HttpServerUtility     server         = HttpContext.Current.Server;
            string                sortExpression = HttpContext.Current.Request.QueryString["order"];
            List <FileFolderInfo> list           = new List <FileFolderInfo>();
            DirectoryInfo         info3          = new DirectoryInfo(p_folderPath);

            try
            {
                foreach (FileSystemInfo info4 in info3.GetFileSystemInfos())
                {
                    string str2;
                    if (string.IsNullOrEmpty(this._FolderPath))
                    {
                        this._FolderPath = HttpContext.Current.Request.PhysicalApplicationPath + "Files";
                    }

                    if (info4 is DirectoryInfo)
                    {
                        DirectoryInfo info = info4 as DirectoryInfo;

                        str2 = "<a href=\"" + Utils.getUrl("" + Utils.getPageUrl() + "?path=" + server.UrlEncode(info.FullName) + "") + "\"> " + info.Name + "</a>";

                        FileFolderInfo info5 = new FileFolderInfo();
                        info5.Name       = info.Name;
                        info5.FullName   = server.UrlEncode(info.FullName);
                        info5.FormatName = str2;
                        info5.Ext        = "";
                        info5.Size       = "0";
                        info5.Type       = "folder";
                        info5.ModifyDate = info.LastWriteTime;
                        list.Add(info5);
                        this._FolderNum++;
                    }
                    else
                    {
                        FileInfo info2 = info4 as FileInfo;

                        str2 = "" + info2.Name + "";

                        FileFolderInfo info6 = new FileFolderInfo();
                        info6.Name       = info2.Name;
                        info6.FullName   = server.UrlEncode(info2.FullName);
                        info6.FormatName = str2;
                        info6.Ext        = info2.Extension;
                        info6.Size       = info2.Length.ToString();
                        info6.Type       = "file";
                        info6.ModifyDate = info2.LastWriteTime;
                        list.Add(info6);
                        this._FileNum++;
                    }
                }
                this._Access = true;
            }
            catch
            {
                this._Access = false;
                return(list);
            }
            if (!string.IsNullOrEmpty(sortExpression))
            {
                list.Sort(new FilesComparer(sortExpression));
            }
            return(list);
        }