Solved

ASP MVC 3 - Modify Directory location

Posted on 2016-08-24
4
35 Views
Last Modified: 2016-08-25
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

0
Comment
Question by:filtrationproducts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
Randy Peterson earned 500 total points
ID: 41769527
It's because the \ is a special character you would need to do + "\\maintenance\\" for it to take.
0
 
LVL 1

Author Comment

by:filtrationproducts
ID: 41770280
That worked. I had to add it in a couple spots but it eventually worked.

Thanks!
0
 
LVL 8

Expert Comment

by:Randy Peterson
ID: 41770444
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.
1
 
LVL 1

Author Closing Comment

by:filtrationproducts
ID: 41770507
Thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question