Note that there are some explanatory texts on larger screens.

plurals
  1. POFile Association
    primarykey
    data
    text
    <p>Is there any way to associate a file with any other file means when any one try to copy any of those file, all associated files also copied. </p> <p>Like OS protected hidden files that are copied when any of associated file is copied. Is there any way to do this in c# or other work around ?</p> <p>Ok i'm going to narrow down by problem. What i'm going to achieve custom icon overlay for specific kind of files. I have implemented this by using a hidden file in a directory that contains name of files whose icons can be overlay. but my problem is that when any of file whose path is writen in that hidden file is moved, the overlay icons are set to default. May be code snippets given below will help to clear my question.</p> <pre><code>[ComVisible(false)] [Guid("1fd5bae8-257a-461a-91ea-869a810e0ccc")] public class MyIconOverlayHandlersBase : IShellIconOverlayIdentifier { string fileName = string.Empty; #region Class Properties protected virtual string OverlayIconFilePath { get { return string.Empty; } } protected virtual string TargetDirectory { get { return string.Empty; } } protected virtual int Priority { get { return 0; // 0-100 (0 is highest priority) } } protected virtual string FileNameStart { get { return fileName; } set { fileName = value; } } #endregion Class Properties #region IShellIconOverlayIdentifier Members public int IsMemberOf(string path, uint attributes) { List&lt;string&gt; filesName = IsHiddenVDFile(path); if (filesName.Count &lt;= 0) { return (int)HRESULT.S_FALSE; } try { string f = Path.GetFileName(path); string newFile = filesName.FirstOrDefault(t =&gt; t.Equals(f)); if (!String.IsNullOrEmpty(newFile)) { unchecked { return Path.GetFileName(path).StartsWith(newFile, StringComparison.InvariantCultureIgnoreCase) ? (int)HRESULT.S_OK : (int)HRESULT.S_FALSE; } } else { return (int)HRESULT.S_FALSE; } } catch { unchecked { return (int)HRESULT.E_FAIL; } } } private List&lt;string&gt; GetFilesName(string info) { List&lt;string&gt; files = new List&lt;string&gt;(); StreamReader reader = new StreamReader(info); string fileNames = reader.ReadToEnd(); string[] f = fileNames.Split('\r'); foreach (string file in f) { files.Add(file.Trim()); } reader.Close(); return files; } private List&lt;string&gt; IsHiddenVDFile(string path) { DirectoryInfo info = new DirectoryInfo(path).Parent; if (info == null) { return new List&lt;string&gt;(); } FileInfo[] files = info.GetFiles(); var filtered = files.Select(f =&gt; f).Where(f =&gt; (f.Attributes &amp; FileAttributes.Hidden) == FileAttributes.Hidden); foreach (var f in filtered) { if (f.Name.Equals("01AVDNames.txt")) { return GetFilesName(f.FullName); } } return new List&lt;string&gt;(); } public int GetOverlayInfo(IntPtr iconFileBuffer, int iconFileBufferSize, out int iconIndex, out uint flags) { string fname = OverlayIconFilePath; int bytesCount = System.Text.Encoding.Unicode.GetByteCount(fname); byte[] bytes = System.Text.Encoding.Unicode.GetBytes(fname); if (bytes.Length + 2 &lt; iconFileBufferSize) { for (int i = 0; i &lt; bytes.Length; i++) { Marshal.WriteByte(iconFileBuffer, i, bytes[i]); } //write the "\0\0" Marshal.WriteByte(iconFileBuffer, bytes.Length, 0); Marshal.WriteByte(iconFileBuffer, bytes.Length + 1, 0); } iconIndex = 0; flags = (int)(HFLAGS.ISIOI_ICONFILE | HFLAGS.ISIOI_ICONINDEX); return (int)HRESULT.S_OK; } public int GetPriority(out int priority) { priority = Priority; return (int)HRESULT.S_OK; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload