Link to home
Start Free TrialLog in
Avatar of filtrationproducts
filtrationproductsFlag for United States of America

asked on

ASP MVC 3 - Modify Directory location

I have the code below and I need to add a directory called "maintenance" after the cID. I tried adding it in manually using '+ "\maintenance\"'  after the + cId but it went all squiggly line on me. I am new the ASP MVC (Razor) so any help would be greatly appreciated!

Thanks!

               {
                    var maintPath = System.Configuration.ConfigurationManager.AppSettings.Get("MaintenancePath");
                    if (System.IO.Directory.Exists(maintPath))
                    {
                        maintPath += "\\" + cId";
                        var files = System.IO.Directory.GetFiles(maintPath);
                        foreach (string file in files)
                        {
                            var fileInfo = new System.IO.FileInfo(file);

                            var maintFile = new Models.ContractorMaintenanceFile(cId, file);
                            if (maintFile.IsValid)
                                fileList.Add(maintFile);
                        }
                    }
                }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Randy Peterson
Randy Peterson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of filtrationproducts

ASKER

That worked. I had to add it in a couple spots but it eventually worked.

Thanks!
Glad that was all you needed.  Just as an FYI if you place an @ in front of the variable it eliminates the special character.  So for example...

string directory = "c://myfolder//somethingelse//"; could be re-written like:

string directory = @"c:/myfolder/somethingelse/";

And those would yield the exact same results.  But with the @ in front, it makes it easier to look at.
Thanks!