public static SetAttribute ( |
||
node | ||
attributeName | string | |
attributeValue | string | |
Résultat | void |
private void GetFiles(XmlNode connectorNode, string resourceType, string currentFolder) { // Map the virtual path to the local server path. string sServerDir = this.ServerMapFolder(resourceType, currentFolder); // Create the "Files" node. XmlNode oFilesNode = XmlUtil.AppendElement(connectorNode, "Files"); System.IO.DirectoryInfo oDir = new System.IO.DirectoryInfo(sServerDir); System.IO.FileInfo[] aFiles = oDir.GetFiles(); for (int i = 0; i < aFiles.Length; i++) { Decimal iFileSize = Math.Round((Decimal)aFiles[i].Length / 1024); if (iFileSize < 1 && aFiles[i].Length != 0) { iFileSize = 1; } // Create the "File" node. XmlNode oFileNode = XmlUtil.AppendElement(oFilesNode, "File"); XmlUtil.SetAttribute(oFileNode, "name", aFiles[i].Name); XmlUtil.SetAttribute(oFileNode, "size", iFileSize.ToString(CultureInfo.InvariantCulture)); } }
private void GetFolders(XmlNode connectorNode, string resourceType, string currentFolder) { string sServerDir = this.ServerMapFolder(resourceType, currentFolder); XmlNode oFoldersNode = XmlUtil.AppendElement(connectorNode, "Folders"); DirectoryInfo oDir = new DirectoryInfo(sServerDir); DirectoryInfo[] aSubDirs = oDir.GetDirectories(); for (int i = 0; i < aSubDirs.Length; i++) { XmlNode oFolderNode = XmlUtil.AppendElement(oFoldersNode, "Folder"); XmlUtil.SetAttribute(oFolderNode, "name", aSubDirs[i].Name); } }
private XmlNode CreateBaseXml(XmlDocument xml, string command, string resourceType, string currentFolder) { xml.AppendChild(xml.CreateXmlDeclaration("1.0", "utf-8", null)); XmlNode oConnectorNode = XmlUtil.AppendElement(xml, "Connector"); XmlUtil.SetAttribute(oConnectorNode, "command", command); XmlUtil.SetAttribute(oConnectorNode, "resourceType", resourceType); XmlNode oCurrentNode = XmlUtil.AppendElement(oConnectorNode, "CurrentFolder"); XmlUtil.SetAttribute(oCurrentNode, "path", currentFolder); XmlUtil.SetAttribute(oCurrentNode, "url", GetUrlFromPath(resourceType, currentFolder)); return(oConnectorNode); }
private void CreateFolder(XmlNode connectorNode, string resourceType, string currentFolder) { string sErrorNumber = "0"; string sNewFolderName = Request.QueryString["NewFolderName"]; if (sNewFolderName == null || sNewFolderName.Length == 0) { sErrorNumber = "102"; } else { // Map the virtual path to the local server path of the current folder. string sServerDir = this.ServerMapFolder(resourceType, currentFolder); try { Util.CreateDirectory(System.IO.Path.Combine(sServerDir, sNewFolderName)); } catch (ArgumentException) { sErrorNumber = "102"; } catch (System.IO.PathTooLongException) { sErrorNumber = "102"; } catch (System.IO.IOException) { sErrorNumber = "101"; } catch (System.Security.SecurityException) { sErrorNumber = "103"; } catch (Exception) { sErrorNumber = "110"; } } // Create the "Error" node. XmlNode oErrorNode = XmlUtil.AppendElement(connectorNode, "Error"); XmlUtil.SetAttribute(oErrorNode, "number", sErrorNumber); }
private void GetFolders(XmlNode connectorNode, string resourceType, string currentFolder) { // Map the virtual path to the local server path. string sServerDir = this.ServerMapFolder(resourceType, currentFolder); // Create the "Folders" node. XmlNode oFoldersNode = XmlUtil.AppendElement(connectorNode, "Folders"); System.IO.DirectoryInfo oDir = new System.IO.DirectoryInfo(sServerDir); System.IO.DirectoryInfo[] aSubDirs = oDir.GetDirectories(); for (int i = 0; i < aSubDirs.Length; i++) { // Create the "Folders" node. XmlNode oFolderNode = XmlUtil.AppendElement(oFoldersNode, "Folder"); XmlUtil.SetAttribute(oFolderNode, "name", aSubDirs[i].Name); } }
private void CreateFolder(XmlNode connectorNode, string resourceType, string currentFolder) { string sErrorNumber = "0"; string sNewFolderName = Request.QueryString["NewFolderName"]; if (sNewFolderName == null || sNewFolderName.Length == 0) { sErrorNumber = "102"; } else { string sServerDir = this.ServerMapFolder(resourceType, currentFolder); try { FileFunctions.CreateDirectory(Path.Combine(sServerDir, sNewFolderName)); } catch (ArgumentException) { sErrorNumber = "102"; } catch (PathTooLongException) { sErrorNumber = "102"; } catch (IOException) { sErrorNumber = "101"; } catch (SecurityException) { sErrorNumber = "103"; } catch (Exception) { sErrorNumber = "110"; } } XmlNode oErrorNode = XmlUtil.AppendElement(connectorNode, "Error"); XmlUtil.SetAttribute(oErrorNode, "number", sErrorNumber); }