Beispiel #1
0
 public void SetLabel(string path, FileLabel label)
 {
     if (label != FileLabel.NOTHING)
     {
         try
         {
             using (var stream = new NTFSDataStream(path, ntfs_stream_name,
                                                    FileAccess.Write, FileMode.OpenOrCreate, FileShare.Read))
             {
                 stream.WriteByte((byte)label);
             }
         }
         catch (NTFSDataStreamException)
         {
             return;
         }
     }
     else if (NTFSDataStream.Exists(path, ntfs_stream_name))
     {
         try
         {
             NTFSDataStream.Delete(path, ntfs_stream_name);
         }
         catch (NTFSDataStreamException)
         {
             return;
         }
     }
 }
Beispiel #2
0
 public FileLabel GetLabel(string path)
 {
     if (NTFSDataStream.Exists(path, ntfs_stream_name))
     {
         try
         {
             using (var stream = new NTFSDataStream(path, ntfs_stream_name,
                                                    FileAccess.Read, FileMode.Open, FileShare.ReadWrite))
             {
                 return((FileLabel)stream.ReadByte());
             }
         }
         catch (NTFSDataStreamException)
         {
             return(FileLabel.NOTHING);
         }
     }
     else
     {
         return(FileLabel.NOTHING);
     }
 }