public bool AddToFileSystem(IFsiDirectoryItem rootItem) { IStream stream = null; try { Win32.SHCreateStreamOnFile(filePath, Win32.STGM_READ | Win32.STGM_SHARE_DENY_WRITE, ref stream); if (stream != null) { rootItem.AddFile(displayName, stream); return(true); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error adding file", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (stream != null) { Marshal.FinalReleaseComObject(stream); } } return(false); }
public bool AddToFileSystem(IFsiDirectoryItem rootItem) { bool flag; IStream stream = null; try { try { Win32.SHCreateStreamOnFileW(this.filePath, 32, ref stream); if (stream != null) { rootItem.AddFile(this.displayName, stream); flag = true; return(flag); } } catch (Exception exception1) { Exception exception = exception1; MessageBox.Show(exception.Message, "Error adding file", MessageBoxButtons.OK, MessageBoxIcon.Hand); } return(false); } finally { if (stream != null) { Marshal.FinalReleaseComObject(stream); } } return(flag); }
private void _AddNode(IFsiDirectoryItem root, IMediaNode node) { IStream stream = null; try { if (node is DirectoryNode) { root.AddTree(node.Path, true); } else { Shell.SHCreateStreamOnFile(node.Path, Shell.STGM_READ | Shell.STGM_SHARE_DENY_WRITE, ref stream); if (stream != null) { root.AddFile(node.Name, stream); } } } finally { if (stream != null) { Marshal.FinalReleaseComObject(stream); } } }
public bool AddToFileSystem(IFsiDirectoryItem rootItem) { IStream stream = null; try { Win32.SHCreateStreamOnFile(filePath, Win32.STGM_READ | Win32.STGM_SHARE_DENY_WRITE, ref stream); if (stream != null) { rootItem.AddFile(displayName, stream); return(true); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "Error adding file"); } finally { if (stream != null) { Marshal.FinalReleaseComObject(stream); } } return(false); }
/// <summary> /// 加文件,完全看不懂啊 /// </summary> /// <param name="root"></param> /// <returns></returns> private bool AddFile(ref IFsiDirectoryItem root) { System.Runtime.InteropServices.ComTypes.IStream stream = null; try { Win32.SHCreateStreamOnFile(m_strThisPath, Win32.STGM_READ | Win32.STGM_SHARE_DENY_WRITE, ref stream); if (stream != null) { root.AddFile(m_strDisplayName, stream); return(true); } return(true); } catch (System.Exception ex) { return(false); } finally { if (stream != null) { Marshal.FinalReleaseComObject(stream); } } }
public bool AddToFileSystem(IFsiDirectoryItem rootItem, CancellationToken cancellationToken, string basePath = "") { if (cancellationToken.IsCancellationRequested) { return(false); } try { var stream = new ManagedIStream(File.Open(Path, FileMode.Open, FileAccess.Read, FileShare.Read)); rootItem.AddFile(System.IO.Path.Combine(basePath, DisplayName), stream); return(true); } catch (Exception) { return(false); } }
public bool AddToFileSystem(IFsiDirectoryItem rootItem) { try { IStream stream = null; SHCreateStreamOnFile(filePath, STGM_READ | STGM_SHARE_DENY_WRITE, ref stream); if (stream != null) { rootItem.AddFile(displayName, stream); return(true); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error adding file", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(false); }
/// <summary> /// add item to burn data tree /// </summary> /// <param name="rootItem"></param> /// <returns></returns> public bool AddToFileSystem(IFsiDirectoryItem rootItem) { IStream stream = null; try { Win32.SHCreateStreamOnFile(filePath, Win32.STGM_READ | Win32.STGM_SHARE_DENY_WRITE, ref stream); if (stream != null) { rootItem.AddFile(_displayName, stream); return true; } } catch (Exception ex) { throw new global::System.InvalidOperationException("Error adding to FileSystem" + ex.Message); } finally { if (stream != null) { Marshal.FinalReleaseComObject(stream); } } return false; }
public bool AddToFileSystem(IFsiDirectoryItem rootItem) { IStream stream = null; try { Win32.SHCreateStreamOnFile(filePath, Win32.STGM_READ | Win32.STGM_SHARE_DENY_WRITE, ref stream); if (stream != null) { rootItem.AddFile(displayName, stream); return true; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error adding file", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (stream != null) { Marshal.FinalReleaseComObject(stream); } } return false; }
private void _AddNode(IFsiDirectoryItem root, IMediaNode node) { IStream stream = null; try { if (node is DirectoryNode) { root.AddTree(node.Path, true); } else { Shell.SHCreateStreamOnFile(node.Path, Shell.STGM_READ | Shell.STGM_SHARE_DENY_WRITE, ref stream); if (stream != null) root.AddFile(node.Name, stream); } } finally { if (stream != null) { Marshal.FinalReleaseComObject(stream); } } }