Ejemplo n.º 1
0
 public Stream getDataFile(string filename)
 {
     lock (this)
     {
         if (Path.IsPathRooted(filename))
         {
             filename = Path.GetFullPath(filename);
         }
         else
         {
             filename = Path.GetFullPath(Path.Combine(writableRootDirectory, Path.GetFileName(filename)));
         }
         if (Path.GetDirectoryName(filename).ToLower() != writableRootDirectory.ToLower())
         {
             throw new AccessViolationException("Access is allowed only in " + writableRootDirectory + ". Use ");
         }
         if (!Directory.Exists(writableRootDirectory))
         {
             Directory.CreateDirectory(writableRootDirectory);
         }
         var quotaStream = new QuotaStream(this, filename, FileMode.OpenOrCreate, FileAccess.ReadWrite,
                                           FileShare.ReadWrite);
         streams.Add(quotaStream);
         return(quotaStream);
     }
 }
Ejemplo n.º 2
0
 public Stream getDataFile(string filename)
 {
     lock (this)
     {
         if (Path.IsPathRooted(filename))
         {
             filename = Path.GetFullPath(filename);
         }
         else
         {
             filename = Path.GetFullPath(Path.Combine(writableRootDirectory, Path.GetFileName(filename)));
         }
         if (Path.GetDirectoryName(filename).ToLower() != writableRootDirectory.ToLower())
         {
             throw new AccessViolationException("Access is allowed only in " + writableRootDirectory + ". Use ");
         }
         if (!Directory.Exists(writableRootDirectory))
         {
             Directory.CreateDirectory(writableRootDirectory);
         }
         var quotaStream = new QuotaStream(this, filename, FileMode.OpenOrCreate, FileAccess.ReadWrite,
                                           FileShare.ReadWrite);
         streams.Add(quotaStream);
         return quotaStream;
     }
 }