Search This Blog

August 5, 2013

Validate if the folder exists on remote server in C#

We have a new feature in this Sprint. The new folders need to be created on the remote server. If I would like to validate if the folders exist on the remote server after we push to different environments (Stage/Prod), the following code works great for me.

Namespace: using System.Net;

string folder = @"\\ServerName\c$\DEV\Data";

var dir = new DirectoryInfo(folder);

if (!dir.Exists)
   Assert.Fail("the folder doesn't exist");

No comments: