Solved

ASP MVC 3 - Modify Directory location

Posted on 2016-08-24
4
32 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
reading excel file in .net 2 31
C# Linq - Join two objects into one 3 33
Query in AngularJS 8 45
Connect Gridview column to Textbox in C# 2 39
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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