Solved

ASP MVC 3 - Modify Directory location

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now