本文整理汇总了C#中FileNode类的典型用法代码示例。如果您正苦于以下问题:C# FileNode类的具体用法?C# FileNode怎么用?C# FileNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileNode类属于命名空间,在下文中一共展示了FileNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshDevices
private void RefreshDevices()
{
tv_dirs.Nodes.Clear();
lv_files.Clear();
if ( devices != null )
{
foreach ( Device dev in devices ) dev.Close();
}
devices = Device.GetPhysicalDevices();
foreach ( Device dev in devices )
{
TreeNode root_node = new TreeNode( dev.DeviceName );
root_node.ImageIndex = 0;
root_node.SelectedImageIndex = 0;
tv_dirs.Nodes.Add( root_node );
List< FileSystem > filesystems = dev.GetFileSystems();
foreach ( FileSystem fs in filesystems )
{
FileNode node = new FileNode( fs.GetRootDir(), true );
root_node.Nodes.Add( node );
}
root_node.Expand();
}
}
示例2: OAVSProjectItem
public OAVSProjectItem(FileNode fileNode)
{
if (fileNode == null)
throw new ArgumentNullException("fileNode");
this._fileNode = fileNode;
}
示例3: OpenDirectory
public void OpenDirectory(string path)
{
this.directory = null;
BeginUpdate();
Items.Clear();
try
{
foreach (string fileName in Directory.GetFiles(path))
{
string ext = Path.GetExtension(fileName).ToLower();
if (supportedExtensions.Contains(ext))
{
FileNode node = new FileNode(fileName);
node.ImageIndex = GetIconName(fileName);
Items.Add(node);
}
}
}
catch (Exception)
{
}
finally
{
EndUpdate();
}
}
示例4: ApplyLogRecordsFilter
public void ApplyLogRecordsFilter(FileNode fileNode = null)
{
var selectedNodes = _fileBrowser.SelectedItems.OfType<FileNode>().ToArray();
if (fileNode != null && !selectedNodes.Contains(fileNode))
{
return;
}
var logRecords = _logTableService.LogTable.Records;
var oldRecords = logRecords.ToArray();
var filteredRecords = FilterRecords(Filter, selectedNodes).ToArray();
_dispatcherService.Invoke(() =>
{
using (logRecords.SuspendChangeNotifications())
{
logRecords.ReplaceRange(filteredRecords);
}
foreach (var record in logRecords.Except(oldRecords))
{
record.FileNode.IsExpanded = true;
}
}, true);
}
示例5: ShouldListEntireTree
public void ShouldListEntireTree()
{
// arrange
IFile childFile;
IFile rootFile;
IFile folder = mockWalker.MockFolder("2", "folder",
childFile = Utils.MockFile("3", "file.txt", "text/plain")
);
IFile rootFolder = mockWalker.MockFolder("root", "root",
rootFile = Utils.MockFile("4", "hello.png", "image/png"),
folder);
IFileNode expected = new FileNode(
Utils.MockFolder("root", "root"), new[]
{
new FileNode(rootFile),
new FileNode(folder, new List<IFileNode>
{
new FileNode(childFile)
})
});
// act
var result = walker.ListRecurse("root");
// assert
Assert.AreEqual(expected, result);
}
示例6: TestMetadata
public void TestMetadata()
{
Dictionary<string, string> metadata = new Dictionary<string, string>();
metadata.Add(FileOp.NextCIdentifierString(random), FileOp.NextNormalString(random));
metadata.Add(FileOp.NextCIdentifierString(random), FileOp.NextNormalString(random));
Test.Info("Metadata is =====================");
foreach (var keyValue in metadata)
{
Test.Info("name:{0} value:{1}", keyValue.Key, keyValue.Value);
}
DMLibDataInfo sourceDataInfo = new DMLibDataInfo(string.Empty);
FileNode fileNode = new FileNode(DMLibTestBase.FileName)
{
SizeInByte = DMLibTestBase.FileSizeInKB * 1024L,
Metadata = metadata
};
sourceDataInfo.RootNode.AddFileNode(fileNode);
var result = this.ExecuteTestCase(sourceDataInfo, new TestExecutionOptions<DMLibDataInfo>());
Test.Assert(result.Exceptions.Count == 0, "Verify no exception is thrown.");
Test.Assert(DMLibDataHelper.Equals(sourceDataInfo, result.DataInfo), "Verify transfer result.");
}
示例7: read
public override FileNode read(string path, string flags, int offset, int length)
{
if (path == "")
{
return this.myroot;
}
else if (getWorkPathArray(path)[1] == "ctl")
{
return null;
}
else if (getWorkPathArray(path)[1] == "new")
{
return null;
}
else
{
int count = 0;
while(count < this.myWindows.Count && this.myWindows[count].Name != getWorkPathArray(path)[1])
{
count++;
}
if(this.myWindows[count].Name == getWorkPathArray(path)[1])
{
FileNode winNode = new FileNode(getWorkPathArray(path)[1], fileTypes.Directory);
return winNode;
}
else
return null;
}
}
示例8: DoValidation
private void DoValidation(FileNode fileNode, int expectedErrors)
{
PropertyInfo fileNameInfo = typeof(FileNode).GetProperty("FileName");
FileValidationAttribute attr = new FileValidationAttribute();
List<ValidationError> errors = new List<ValidationError>();
attr.Validate(fileNode, fileNameInfo, errors, ServiceProvider);
Assert.AreEqual(expectedErrors, errors.Count);
}
示例9: LoadImage
private void LoadImage(FileNode node, ListView targetListView)
{
var key = node.File.FullName;
var item = targetListView.Items.Add(key, node.File.Name, DefaultImageKey);
node.BlockingLoadImage();
ImageList.Images.Add(key, node.Image);
item.ImageKey = key;
}
示例10: WaitUntilFileCreated
public static void WaitUntilFileCreated(string rootPath, FileNode fileNode, DataAdaptor<DMLibDataInfo> dataAdaptor, DMLibDataType dataType, int timeoutInSec = 300)
{
Func<bool> checkFileCreated = null;
if (dataType == DMLibDataType.Local)
{
string filePath = dataAdaptor.GetAddress() + fileNode.GetLocalRelativePath();
checkFileCreated = () =>
{
return File.Exists(filePath);
};
}
else if (dataType == DMLibDataType.PageBlob ||
dataType == DMLibDataType.AppendBlob)
{
CloudBlobDataAdaptor blobAdaptor = dataAdaptor as CloudBlobDataAdaptor;
checkFileCreated = () =>
{
CloudBlob cloudBlob = blobAdaptor.GetCloudBlobReference(rootPath, fileNode);
return cloudBlob.Exists(options: HelperConst.DefaultBlobOptions);
};
}
else if (dataType == DMLibDataType.BlockBlob)
{
CloudBlobDataAdaptor blobAdaptor = dataAdaptor as CloudBlobDataAdaptor;
checkFileCreated = () =>
{
CloudBlockBlob blockBlob = blobAdaptor.GetCloudBlobReference(rootPath, fileNode) as CloudBlockBlob;
try
{
return blockBlob.DownloadBlockList(BlockListingFilter.All, options: HelperConst.DefaultBlobOptions).Any();
}
catch (StorageException)
{
return false;
}
};
}
else if (dataType == DMLibDataType.CloudFile)
{
CloudFileDataAdaptor fileAdaptor = dataAdaptor as CloudFileDataAdaptor;
checkFileCreated = () =>
{
CloudFile cloudFile = fileAdaptor.GetCloudFileReference(rootPath, fileNode);
return cloudFile.Exists(options: HelperConst.DefaultFileOptions);
};
}
else
{
Test.Error("Unexpected data type: {0}", DMLibTestContext.SourceType);
}
MultiDirectionTestHelper.WaitUntil(checkFileCreated, timeoutInSec);
}
示例11: EnsureCanWriteToAValidFile
public void EnsureCanWriteToAValidFile()
{
string fileName = Path.GetTempFileName();
FileNode fileNode = new FileNode(fileName);
using (File.Create(fileName))
{
}
DoValidation(fileNode, 0);
if (File.Exists(fileName)) File.Delete(fileName);
}
示例12: printAllFileEntries
public static void printAllFileEntries(FileNode Root)
{
Console.WriteLine("Node: " + Root.NodeName);
foreach (RARC.FileEntry f in Root.Files) {
Console.WriteLine(" Entry:" + f.FileName);
}
foreach (RARC.FileNode n in Root.ChildNodes)
printAllFileEntries(n);
}
示例13: ShouldCopyChildren
public void ShouldCopyChildren()
{
IFileBase fileInfo = Mock.Of<IFileBase>(f => f.Id == "parent");
IFileBase childFileInfo = Mock.Of<IFileBase>(f => f.Id == "child");
FileNode fileNode = new FileNode(fileInfo, new List<IFileNode>
{
new FileNode(childFileInfo)
});
Assert.AreEqual("child", fileNode.Children[0].Id);
}
示例14: AddOneFileInBytes
public static void AddOneFileInBytes(DirNode dirNode, string fileName, long fileSizeInB, FileAttributes? fa = null, DateTime? lmt = null)
{
FileNode fileNode = new FileNode(fileName)
{
SizeInByte = fileSizeInB,
FileAttr = fa,
LastModifiedTime = lmt,
};
dirNode.AddFileNode(fileNode);
}
示例15: FileCount_FolderWithOneFile
public void FileCount_FolderWithOneFile()
{
IFileBase fileInfo = Utils.MockFolder("root", "root");
IFileBase childFileInfo = Utils.MockFile("file", "file", "text/plain");
IFileNode fileNode = new FileNode(fileInfo, new List<IFileNode>
{
new FileNode(childFileInfo)
});
Assert.AreEqual(1, fileNode.FileCount());
}