w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
StreamReader Server.MapPath - Physical path given, virtual path expected
MapPath translates paths starting from ~ to full local path. Does not look like you need it in your code. If the file is supposed to be at fixed place all the time, open in directly by full path. If it is relative to site root, then use something like Server.MapPath("~/status.txt")

Categories : C#

Server.MapPath returning a path with a folder that doesn’t exists
I don't believe MapPath guarantees that a path exists, it just tacks your virtual path to the context path. I think your problem is that you're using HttpContext.Current.Server.MapPath try using HttpContext.Current.Request.MapPath

Categories : Dotnet

500 internal server error on asp.net page caused probably by server.MapPath
The problem is you're trying to save to the App_Data folder - this folder is only available to actual code. You cannot write to it by default, you also cannot output its contents to your website. The App_Data is specifically meant for Data only - such as XML & Database files - see here for more info: MSDN App_Data folder So, even if you managed to save a file into app_data you would not be able to display it - you would receive an unauthorized access error message. To fix, change this: HttpContext.Current.Server.MapPath("~/App_Data/setP") to something like this HttpContext.Current.Server.MapPath("~/uploadImages/setP") Essentially give yourself a different folder to upload to. Update Following from the comments it seems you are getting the A Generic error occurred in GDI+...

Categories : Asp Net

ASP.net file upload from a non server - issue with Server.MapPath?
You wrongly getting file name. You should use below code string filename = Path.GetFileName(FileUploadControl.FileName); Of course change control name to your own. Please See: http://msdn.microsoft.com/en-us/library/aa479405.aspx

Categories : Asp Net

Using Server.MapPath to save a file
You can access it through the current context HttpContext.Current.Server.MapPath("~/App_Data/stored"); to get the full file path : var filePath = Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data/stored"), package.Id + ".zip");

Categories : Asp Net

Using Server.MapPath() to generate img src, not working
APP_Data is a restricted folder intended for Datasources such as Database only. ASP.Net will not deliver a file in here - try it by going to the URL for that image directly (I.E www.mysite/App_Data/5/62.jpg ) and you will see the error message HTTP Error 403 - Forbidden. Put your images in a folder outside of this and you will be fine, such as a folder in the root Called Images

Categories : Asp Net

Server.MapPath() with IIS URL Rewrite Module 2.0
I was looking for the same thing so I gave it a try in a test app. It appears that Server.MapPath() does not acknowledge URL Rewrite Module rules. Here is how I tested using an empty web project (Razor syntax): Rewrite rule: <system.webServer> <rewrite> <rules> <rule name="Rewrite rule1 for test1"> <match url="^test1(.*)" /> <action type="Rewrite" url="{R:1}" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> cshtml: <p> The URL for this page is @Request.Url.AbsoluteUri . <br /> MapPath of /test1 is @Server.MapPath("~/test1") <br /> MapPath of / is @Server.MapPath("~/") </p> I

Categories : Iis

Why won't File.copy work with Server.MapPath
Server.MapPath is a secure method, and requires that you have AspEnableParentPaths set to true for your application. http://msdn.microsoft.com/en-us/library/ms524632(v=vs.90).aspx

Categories : Asp Net

How we Redirect one Page to AnotherPage with Server.MapPath
you don't need MapPath here, since you have relative path you can directly call Response.Redirect Response.Redirect("~/ReportPage.aspx"); Server.MapPath will return physical path of given file. For example when we need to read TEXT file inside root folder var lines = File.ReadAllLines(Server.MapPath("~/temp.txt")); But in your case no need of a Server.MapPath

Categories : C#

Cannot use Server.MapPath to access a external file
Server.MapPath works only with files that are inside the website and is used by specifying a relative location: string configFile = Server.MapPath("~/App_Data/config.xml.config"); If you want to access a file from some other location you will have to manually provide the absolute path to it: string configFile = @"c:worksome_folderconfig.xml.config";

Categories : C#

What using directive do I use for Server.MapPath in a separate .cs file in WebMatrix?
You can assign the Server property to a variable to save a bit of typing: var server = HttpContext.Current.Server; var file = server.MapPath("~/SomeDirectory/Somefile"); To answer the question posed in the title of your post - the using directive you need in the class file is System.Web: using System.Web; I don't know of any "cheat sheet" as such. Experience and a growing familiarity with MSDN help, as does Resharper if you can afford it and have the full version of Visual Studio.

Categories : C#

httpcontext.current.server.mappath and unit testing
You need to abstract out the loading of the XML file. Such as; class WebContentLocator : IContentLocator{ public string GetPath(string relativePath) { return HttpContext.Current.Server.MapPath(relativePath); } } class TestContentLocator : IContentLocator{ string _contentRoot; public TestContentLocator() { _contentRoot = ConfigurationManager.AppSettings["ContentRoot"]; } public string GetPath(string relativePath) { return Path.Combine(_contentRoot, relativePath.Replace("~", string.empty); } } interface IContentLocator { string GetPath(string relativePath); } and in your test inject the TestContentLocator into the code that is doing the XML loading, which would by default be using the WebContentLocator. Fds.ReadXml(_content

Categories : Asp Net Mvc

httpcontext current server mappath shows c:inetpubwwwroot when the current location is somewhere else
Use Server.MapPath("~"), which returns the physical path of the root of your application. The Server.MapPath("/") you are using, returns the physical path of the root of the domain.

Categories : Asp Net Mvc

Changing URL without changing Actual Path to Redirect
ASP.NET MVC 4 provide a toolbox way to write your application. The URL that you see in the browser comes from Routing that do the hard work to convert url to app routes and app routes to url. 1) The default ASP.NET MVC 4 Template project comes with a file at App_Start folder named RouteConfig, where you must config the routes for the app. 2) The routes has precedence order, so, put this route before the default one: routes.MapRoute( name: "RouteForPageId", url: "{pageId}/{action}", //controller = "Home" and action = "Index" are the default value, //change for the Controller and action that you have //pageId is the parameter from the action that will return the page defaults: new { controller = "Home", action = "In

Categories : Asp Net Mvc

How do i open a file from different path(not the server default path) using file_put_content in php
When placing files on your computer you can either use relative or absolute path like this: // absolute path $file = "C:/temp/test.txt"; // relative path from C:/Program Files/wamp/htdocs/index.php $file = "../../temp/test.txt"; Both of those files point to the same place

Categories : PHP

Changing Cronjob path
Your script is not in the directory: /$HOME/Documents/crontest.py You say at the bottom that it's in: /home/meric/crontest.py /usr/bin/crontest.py Why not copy it to: $HOME/Documents/crontest.py and try again.

Categories : Bash

What is the best way to handle path when changing language?
Look at $_SERVER['QUERY_STRING']. http://php.net/manual/en/reserved.variables.server.php or Try, $arr=$_GET; $arr['lang']='fr'; <a href="index.php?<?php echo implode('&',$arr); ?>">Change to French</a>

Categories : PHP

Storing the path geometry and changing it later
Simple Example for Ellipse properties: <Path Fill="Gold" Stroke="Black" StrokeThickness="1"> <Path.Data> <EllipseGeometry Center="50,50" RadiusX="{Binding RadiusX}" RadiusY="50" /> </Path.Data> </Path> And in your ViewModel (or DataContext if you are not using the MVVM design pattern) define a property (Either Notifiable using the INotifyPropertyChanged or a DependencyProperty) that has the name RadiusX. now when you change it , it should update your geometry display. This can also be done for a Path Geometry : For that you will have to one of 2 thing: 1) have a property of type PathGeometry as explained above and use it regularly: <Path Data="{Binding PointsForPath}"/> 2) have another data structure that holds your points the way you wa

Categories : C#

Changing the end point of a path in raphael
One way to modify a part of the path is to store the path details in an array, modify parts as required and reassign the path as string. var paper = new Raphael(document.getElementById('canvas_container'), 500, 500), pathArray = ['M', 100, 100, 'l', 100, 100, 0, 100, 'z'], shape = paper.path(pathArray.join(' ')); // Modify the last point (0, 100) to (100, 0) pathArray.splice(-3, 2, 100, 0); // Reassign the path as string shape.attr({path: pathArray.join(' ')}) Hope this helps.

Categories : Jquery

Changing activity background by path
A resource ID is just an integer--there's no need to deal with strings. You can use something like this int[] imageIds = new int[] { R.drawable.bg1, R.drawable.bg2, ... }; , pick a random element, and set it as your background. Not sure if you can encode the array of resource IDs in xml.

Categories : Android

Shortcuts changing the relative path?
I am not in a position to propose a direct solution for your specific problem. On the other hand, I have had some paths/relative-reference problems in the past when working with different Windows installer packages which I solved by running a program passing all the required information to the installer. Example of what I mean: A small program is executed right before starting the installation. It retrieves all the required information (e.g., desktop's path) and writes it to a temporary location (e.g., Windows Registry). The main installation package is started, reads/deletes the information from the temporary location and brings it into account while performing the installation (e.g., path for the shortcuts). Depending upon the available setup options, you might perform the aforement

Categories : C#

Accessing HostingEnvironment.MapPath() within class called by webservice / website
In the end I've found the following solution: Set the properties on the dependent files: Copy to Output Directory = Copy if newer This copies the files into the bin folder of the Hosting Environment (so it will copy it into either the WCF Service or the WebApplication from the Class Library) HostingEnvironment.ApplicationPhysicalPath then returns this location The difference is the files are being copied cross project when building (I didn't know copy if newer did this). I can therefore access the files from the applications' bin (and not from the Class Library as I was attempting before).

Categories : C#

Python CSV.Writer changing saving path
Use the tkFileDialog module. Example: import tkFileDialog with open(tkFileDialog.asksaveasfilename(), "w") as fp: ...

Categories : Python

Xcode - Changing library reference path
It sounds like you might need to add an @rpath entry to your .xcconfig file. It would probably look something like this: LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks/

Categories : Osx

Changing the path/filename of SplashScreenImage.jpg in Windows Phone 8
Nope, still the same "problem", splash screens must be placed at root level. However, you can have several splash screens depending on the client's resolution. Check here for more tips on how to create splash screens for your WP apps. http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769511%28v=vs.105%29.aspx

Categories : C#

API path different from dev to test to prod. How do I avoid changing between deployments?
I have the following JScript code:var apiUrl = "/api/myService/myMethod/ Don't have such code. Never hardcode urls in an ASP.NET MVC application. You should always use helpers when dealing with urls. So for example you could have this in a global variable in your Layout: <script type="text/javascript"> var apiUrl = '@Url.Route("DefaultApi", new { controller = "values", httproute = "" });'; </script> You are undoubtedly noticing the httproute = "" route parameter I used in order to indicate to the URL helper to use the Web API routes and not your MVC routes (which are 2 entirely different things). But in most cases you don't even need that. The url that you are passing to this $.getJSON function could be part of your DOM. For example you never call this $.getJSON fu

Categories : Javascript

Laravel 4 - changing resource root routing path
I just tested with new resource controller and it works fine for me. The problem is not with the Route, its with the named routes used in your application. check your view files there are link to route like link_to_route('tweets.create', 'Add new tweet'), this is creating the error because when you add admin as prefix tweets.create doesn't exists so change it to admin.tweets.create every where, in your controller also where ever named route is used.

Categories : Laravel

Shell - Change file name without changing extension from a given path
This could be one way: find "$input_variable" -type f -name "$word.*" | while read file; do dir=${file%/*} base=${file##*/} ext=${base##*.} noext=${base:0:${#base} - ${#ext} - 1} newname=${noext/"$word"/"$replace"}.$ext echo mv "$file" "$dir/$newname" done Remove the echo part when you're sure it's already correct. Edit: find "$input_variable" -type f -name "$word.*" | while read file; do dir=${file%/*} base=${file##*/} noext=${base%.*} ext=${base:${#noext}} newname=${noext/"$word"/"$replace"}$ext echo mv "$file" "$dir/$newname" done

Categories : Linux

Change path color without changing previous paths
The problem here is you only use one Path. You should create a new Path on every ACTION_DOWN. And for each of theses path you have to store the Paint as well. For example you can define a class with both elements as members: public class Stroke { private Path _path; private Paint _paint; }// add constructor(Path, Paint) and accessors And a list of Stroke in your Context: List<Stroke> allStrokes = new ArrayList<Stroke>(); So on every ACTION_DOWN, you create an new Stroke (so a new Path, and a new Paint with your choosen color). And on every ACTION_MOVE, you have retreive the last added Path, then you can lineTo the last point. Then on your onDraw, just draw all created Stroke: for (Stroke s : allStrokes) { canvas.drawPath(s.getPath(), s.getPaint()); } N

Categories : Android

Error while changing path for image in joomla website
As @David Fritsch states paths in the CSS should work as they are relative to the website root. It's more likely to be a configuration issue than a need to change the CSS. Try to diagnose the problem: Check what path the browser is looking at: try Right-clicking a broken image and selecting "Open image in new window/tab" to see the address the browser is trying to access. Check your new servers access logs to compare the image request(s) with the actual file location. Look for things like extra directories in the path the browser is trying access (or missing ones). To get better help provide more detail in your question, like the URL for the site or the HTML in the page versus the path to the actual image files.

Categories : PHP

Changing image's relative path to full url in RefineryCMS-Blog
The way I eventually had to do it was similar to this gist. I essentially used the same code (below) but put it in a different function somewhere else. The reason a substitution was necessary was because the wysiwyg editor hardcodes it. The way to combat it is to either change it on the way in or the way out. If you only use it one or two times, then using this function on the way out was easiest (but probably less correct). Be sure you set your asset_host values in the config files to ensure this works. def use_full_paths(existing_content) existing_content.gsub!(%r{src="(/system)}) do |m| m.to_s.gsub( %q{src="}, %Q{src="#{Rails.application.config.action_controller.asset_host}#{m.gsub('src="/system', '')}} ) end if existing_content.present? existing_conte

Categories : Ruby On Rails

Programmatically changing backup file path of a Back Up Database task on SSIS
You may want to try this solution. Drag and drop a Foreach Loop Container and define a collection with paths where the backup files will be saved In the Variable Mappings tab define a variable which will hold a location for a backup file Place a Back Up Database Task inside of the Foreach Loop Container. Go to the Properties of the Back Up Database Task, open the Expressions window. Choose a DestinationAutoFolderPath and in the expression window use the previously define variable. Done.

Categories : Sql Server

Find and update in nested json object without changing the same key-pair value in different child path
I think you can somehow use a path to locate the value and then do the update. I got the idea from this post. (answered by @shesek) var getPath = function (obj, path, newValue) { var parts = path.split('.'); while (parts.length > 1 && (obj = obj[parts.shift()])); obj[parts.shift()] = newValue; return obj; } console.log(getPath(TestObj, 'Categories.0.Products.1.id', 'AAA')) console.log(TestObj) So you can pass in the path to the object, for example, if you want to update the id of the following object to "AAA", you can pass in Categories.0.Products.1.id { "id": "a02", "name": "Pine", "description": "Short description of pine." } then, the object will become { "id": "AAA", "name": "Pine", "descript

Categories : Javascript

Changing Request URL by the Server
You can store slugs for contents with ids. If you look at $_SERVER you'll find the requested url. So if it does not contain the slug then you can look it up in the db and redirect to it.

Categories : PHP

Changing server for SQL database
I think you should create a new user at the old database with the same name of the new user at the new database before you backed up and exported the database. for example you have in the new hosting site a user "user1" you should add the user "user1" at the existing database before you exported it and imported it to the new site.

Categories : Mysql

How to prevent rails from changing the path when the edit action is rendered from update action
The reason you were in /users/1 is the view is rendered by #update, not #edit. By default resource the path of #update is same as #show, with different request method GET and PUT. So, when #update renders HTML response, it's same as #show. I think the result is acceptable, no matter what path your are in the result is expected. As you already found, if using redirect, the @user instance will be changed to a branch new one thus losing errors and previous fillings. There is workaround on the path such as using session to pass instance variable, but I don't think it worth the effort. The current result is good enough. Add Manipulating active states is easy. I don't like current_page? which needs too much code. Use controller_path and action_name instead. if controller_path == 'users'

Categories : Ruby On Rails

In C# MVC4 how to get the server path?
Use the Request.Url property available in Controller. This returns a Uri object containing info on the request. From there, you can access the AbsoluteUri and Port properties to get the info that you need. If you are interested in getting the url info from SignalR, try looking at this question and answer.

Categories : C#

Why can I run this file packaged by Maven by specifying the path as argument but not by setting the path permanently in my path variable?
You'll need to add the storm dependencies to your classpath - it's currently not included because it is marked as 'provided' in the m2-pom.xml, change it to 'compile': <dependency> <groupId>storm</groupId> <artifactId>storm</artifactId> <version>0.8.2</version> <scope>compile</scope> </dependency>

Categories : Java

scope of `this` changing on a production server?
You are getting the error because the this context is lost in the inner function you are passing to SC.record and no longer refers to your Backbone view. There a few ways around this, one of which is to take advantage of closures and create a reference to the correct this and use it in the progress callback: StartRecording: function(e){ var self = this; $('#startRecording').hide(); $('#stopRecording').show(); e.preventDefault(); SC.record({ progress: function(ms, avgPeak) { self.updateTimer(ms); } }); }, Same thing goes for the call to updateTimer in the call to SC.recordPlay in Playback.

Categories : Javascript

Store CSV into server without changing Datatype
Can you try format number to string like below Dim style As String = "<style>.textmode{mso-number-format:@;}</style>" Refer : http://www.aspsnippets.com/Articles/Export-GridView-To-Word-Excel-PDF-CSV-Formats-in-ASP.Net.aspx

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.