0

We have to write a file in one drive (L) which is the shadow copy of the C drive. We tried with normal like below.

string datFile = "L:\\DATA\\ABC.DAT";

string message = "test";
        try
        {

            using (StreamWriter writerAppend = new StreamWriter(datFile, true))
            {
                writerAppend.WriteLine(message);


            }


        }

But it is giving error

System.IO.DirectoryNotFoundException: Could not find a part of the path 'L:\DATA\ABC.DAT

Please help if there is any specific way to access it.

Anto Varghese
  • 3,131
  • 6
  • 31
  • 38
  • 1
    [Shadow copy volumes are read-only.](http://technet.microsoft.com/en-us/library/cc785914%28v=ws.10%29.aspx) – Dark Falcon Oct 01 '14 at 12:23
  • @DarkFalcon si that then the normal error message for trying to access the non writeable shadow volume? (I would expect a different IO error tbh oO) – Thomas Oct 01 '14 at 12:38
  • No, probably not, but it is hard to say. I've never tried it. – Dark Falcon Oct 01 '14 at 12:39
  • Same here and in addition didnt even know till this questoin that microsoft offers such a feature for a few operating systems. For the originalposter: Are you sure that L:\DATA exists ? If so can you try the same code on a non shadow copy volume ? (it could be that as dark falcon mentioned them being read only that the read only part causes the problem, although like I mentioned I would expect a different error message there with a non shadow copy drive it could be made sure that its really coming from the shadow copy and not some different reason) – Thomas Oct 01 '14 at 12:43
  • Is there a folder `Data` on disk `L:` already? `StreamWriter` will create file no prob, but it **can't** create directory. – Sinatr Oct 01 '14 at 12:45
  • @Thomas yes the DATA exists. I can see those folder while I am remotely connecting. Also I notice one difference is that programmatically when I tried to access the drives in it, it is not listing out the L drive. Strange. But I can see it in my computer as Local Dist. – Anto Varghese Oct 01 '14 at 12:53

0 Answers0