Formatting A String - Paths

Jan 7, 2011

I have the following code, which generates insert queries

For Each f As String In Directory.GetFiles(d)
objSQLStringBuilder.Append("insert into table1 (full_path, file_name) values ('" & f.Replace("'", "''") & "', '" & f.Remove(0, Len(d) + 1).Replace("'", "''") & "');")
Next

However, the paths which it finds are formatted as follows c:program filesmicrosoft officewinword.exe I need to format the paths as follows file:///c:/program%20files/microosoft%20office/winword.exe. How can I modify the above code to do this?

View 5 Replies


Similar Messages:

MVC String Formatting C# - Show 20 Characters Of 100 - Trim / Cut String?

Aug 23, 2010

I want to show just a part of a string for example:

Instead: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."

Just a: "Lorem ipsum dolor sit amet, consetetur sadipscing..."

Which method can I use to do that?

View 3 Replies

Correct Formatting On String?

Apr 5, 2010

I've been wrestling with this for a while, and I just can't seem the get the correct amount of quotes in the correct place, so as a last resort, I'm hoping someone could attempt to correct it.

[Code]....

View 3 Replies

Formatting TimeSpan To String Text?

Jul 26, 2010

I have a calculation that takes place utilizing the TimeSpan.FromTicks method, the result is stored in a TimeSpan object. The calculation itself is working correctly, but I'd like to format the result a bit nicer than it is and I can't figure out how to format a TimeSpan.

The result from the TimeSpan is:

00:00:04.6153846

I'd like to remove any preceding zero's and round up to the second decimal place, such as:

4.62

Does anyone know how I might be able to accomplish this? I can't seem to find a .NET 'built in' solution.

View 1 Replies

.net String Formatting - Non Breaking Space

Mar 4, 2010

DateTime.Now.ToString("h:mm tt")

What is the proper way to.. escape if that is the proper term, that html entity so that it will produce the output Code: 8:53 am and the non breaking space is rendered correctly be the browser?

View 1 Replies

Datetime Formatting With String.format

Sep 23, 2010

I have a table in my SQL DB that is a DateTime table, what I want to do is take the numeric datetime it stores and convert it to a long date (i.e. 12/12/2012 conversts to December 12, 2012). Seaching the forums it looks like the string.format is the way to go and searching for info on that I found [URL] which lists all the different formats but they do not list a formating string to convert to the format I want to use. Does anyone know what format string I would use to convert a numeric date to a long date like I want? And can you show it in a code example because I am not 100% sure I understand the code examples shown on that site.

View 4 Replies

ADO.NET :: Converting Date To String And Formatting It Linq To SQL?

Aug 2, 2010

I have problem in converting date to string I am using cstr(p.tripstart) , which is returning Date as 12 Aug 2010 12:AM I need to make formating This is my code :

[Code]....

View 9 Replies

Web Forms :: Formatting And Converting Object To String?

Oct 6, 2010

I am fetching data from MySql database.When i look at the object it looks like this:But when this object is converted to String then it appears like this:The Formatting of the object is gone..How can i get/show the original formatting that is fetched from the database..

View 5 Replies

Formatting .net Label When The Value Is Sourced From A Query String?

Oct 11, 2010

I have a label I want to display as a lovely number format i.e. {0:N0} Now, this label text equates to a query string value.How do I go about formatting a label's text from a query string value in one fell swoop?I have tried this

lblTotalPurchQS.Text = String.Format("{0:N0}",Request.QueryString["totalpurchasequantity"].ToString());

View 1 Replies

C# - Saving String To SQL Including Line Breaks For Formatting?

Feb 10, 2011

I want to be able to store strings in the DB but some are long and i want to format them such that when i copy them out of SQL and past them into notepad they have line breaks to break up the otherwise single line that runs on forever and hard to read.

lets say i am storing a string of all the session variables like this, how do i include line breaks in here?

StringBuilder theBody = new StringBuilder();
theBody.Append("Session Values: " + "
");
foreach (string s in Session.Keys)
theBody.Append(s + ":" + Session[s] + "
");

View 1 Replies

ASP Literal Or Page Altering HTML String Causes Formatting

Jun 16, 2010

We have a service that generates a report (using word templates and a 3rd party library), and then returns a string in HTML. While this HTML isn't great - its formatted correctly in this string. We want this HTML to show up on a page - format intact. What we currently have done is set an ASP.net Literal's text element to this string. While this works, I have noticed that it has reformatted the HTML string slightly. For the most part, it looks like it generated a bunch of new CSS classes, and a new style element in the HTML. This HTML does not exist in the string thats being returned. I could filter all of this back out, but wonder if there is a better way. I assume that the Page itself is altering something. What is the best way to display this raw HTML back to the user? I can't directly use a Response.Write(string), because this page does have a few other controls on it.

View 3 Replies

Forms Data Controls :: Conditional String Formatting Within Repeater?

Mar 29, 2011

In my repeater I am attempting to set the label format based on a value from my datasource. The following line from my repeater is straightforward enough but now how would I modify it if I wanted the "C2" statement in the ToString to pull from a field in my datasource named "MyFormat" which would contain either the C2 or N0 value? Basically switching the formatting for that label between currency and a double?

<asp:Label runat="server" ID="lblValue1" Text='<%# Convert.ToDouble(Eval("MyValue")).ToString("C2") %>'></asp:Label>

I've attempted to simply insert a statement such as Eval("MyFormat") in place of the "C2" statement but to no avail.

View 2 Replies

Forms Data Controls :: Load Formatting String From Web.config File?

Jan 13, 2011

I am trying to create a control, but I need to load my formatting string from my web.config file, but every time I try to run the program I get an error one the formatting line. show me the correct syntax to load this data?

[Code]....

View 6 Replies

Forms Data Controls :: Data Formatting From String To Boolean?

May 4, 2010

I have the following code that works fine:

[code]....

View 7 Replies

Forms Data Controls :: Formatting Date In Textbox - Getting Error "String Was Not Recognized As A Valid DateTime"

Jan 7, 2011

I am having trouble formatting the date on a textbox I get the error above if I don't enter the date in MM/DD/YY format in the textbox. I am also using this in a FormView so I can't format it or don't know how to in the code behind so if there is a way to format it in design view that would be preferable. Does anyone have any ideas on how I would do any of this.

<asp:TextBox Text='<%# Bind("BIRTH_DATE", "{0:d}") %>' Font-Names="Tahoma"
Font-Size="X-Small" ToolTip="MM/DD/YYYY" ID="txtBirthDate" runat="server"
TabIndex="2" CssClass="style5"></asp:TextBox>

View 2 Replies

MVC String Formatting C# - By 100 Characters Make 4 Rows Each 25 Characters?

Aug 23, 2010

I have a string with 100 characters and it is for me too long in one line. I want to make NewLine after each 25 characters. For example:

Instead: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."

View 2 Replies

Getting Different Paths Using HttpPostedFileBase?

Feb 7, 2011

See the following code. I'm uploading files, Yet i'm getting different results from difference browsers.

Firefox var path = "about.restaurant.jpg"
yet in ie6 path = "D:devxxxxxxxxxxxxxxxWebsiteimagesabout.restaurant.jpg"
foreach (string file in Request.Files)

[code]...

View 1 Replies

MVC :: Want To Create Two Controllers/Paths?

Sep 16, 2010

I am wanting to create a path somewhat like this: /Administration/News and have it forward to a News controller instead of it being the action.How would I go about this?

View 3 Replies

C# - Linking To Resources (img, Css, Js) From Different Paths?

Feb 28, 2011

Iam new to ASP.NET and poking around my first ASP Web Application projects in .NET 4.0 I have problem, which I can't solve, and google searches does not bring any joy. So I would ask for and/or explanation of following problem:

Assume that I have set up following project structure:

default.aspx
[gfx] (dir)
[images]
picture.jpg
[css]
stylesheet.css

[Code]....

View 5 Replies

HTML Img - ASP Image And Relative Paths

Mar 4, 2011

What is the correct way to reference an image in ASP.NET for live deployment on IIS? The following works in dev and production:

<asp:ImageButton ID="ibnEdit" runat="server" OnClick="ibnEdit_Click" ImageUrl="~/App_Themes/Default/images/one.png" Visible="false" ToolTip="Edit" />

The following doesn't work in either: (why not?)

<img src="~/App_Themes/Default/images/two.gif" />

The following works in dev but not in production:

<img src="../App_Themes/Default/images/two.gif" />

View 2 Replies

Configuration :: Deployed DLL Contains Wrong Paths?

Sep 30, 2010

This may be a dumb question, but I've got a DLL that I compile and reference locally in a web site project and everything runs just fine. When I deploy this solution to the test server, I get an "Object reference not set to an instance of an object." error and the stack trace displays the files with their paths that are causing the error. The thing is, the paths being displayed are the absolute path as they existed on my development machine. Here's the stack trace:.........................

View 3 Replies

C# - Routing And Physical Paths In Web.config?

Jul 22, 2010

I use ASP.NET routing to rename the full paths of my URLs (ie. /page1/page2/file.aspx would just become /file.aspx). This doesn't work with web.config authorization, because that uses physical path/folder names.

View 1 Replies

Vb.net - .NET Theming Programatically : Image Paths?

Mar 14, 2011

We have a multilingual site, or culture-sensitive, and some of the static content now needs to be targeted; for this I'm using themes as it seems the easiest way to achieve what I want, but I can't for the life of me get the images to pick up.I'm setting the theme in code-behind, and thought at first that maybe this was the issue, but on checking up it looks like I'm doing the right thing (setting on Pre-Init).

I expect to be able to reference images using relative paths where App_Themes/ThemeName/ is automatically resolved, such as:

<asp:Image runat="server" ImageUrl="imagesimage.jpg"/>

For whatever reason, however, the image isn't being pulled through at all.This is the code we have in place for setting the theme (the only really relevant part, I'm sure, being the Theme = CurrentSite.CultureName, which is applied successfully):

Private Sub SetTheme()
Dim themesPath = Server.MapPath("~/App_Themes")
If Directory.Exists(themesPath) Then[code]...

In the above code, CurrentSite.CultureName would be a language culture name (for example, en-gb, or nn-no) that does have an existing corresponding theme folder containing all required resources.Pages do have EnableTheming set to True. Also, I have tried removing the theme-setting code and applying the theme in the page using Theme="en-gb" to no avail.

Is there anything immediately evident as to why the URLs aren't resolved?

View 1 Replies

C# - Mapping A Filename To Paths On A Server?

Jun 28, 2010

I have a problem with my code. My code is using the fileupload control to browse for a filename when you add a filename it processes it and the code runs fine on when it lives on local host, but when I put the code on our prodution server it cannot find the filenames listed by user.

For example if I use the upload control to browse to B:MISCH IntiveRPTTOFL_3.csv and the code lives on my localhost which know what that file path means it works, but if the code is moved to a production server it may or maynot know what B:/ is or B:/ maybe mapped to something else. Even if I am browsing to a file on my C drive it will work on if the code is on the machine that the C drive is on, but it will not work if the code is on another machine because obviously that file wouldnt be on that C drive.

Private Function CSV2DataTable(ByVal filename As String) As DataTable

Using MyReader As New _
Microsoft.VisualBasic.FileIO.TextFieldParser(filename)
MyReader.TextFieldType = FileIO.FieldType.Delimited

What can I do in asp.net to make the filename work correctly?

Ok lets say I get the filename and save it as so

FileUploadControl.SaveAs(Server.MapPath("~/") + filename);

now I want to pass the filename to the function above for processing. Do I pass Server.MapPath("~/") + filename as the filename? Also when I am done what do I do to delete the file from the server?

View 1 Replies

Web Forms :: Getting .aspx File Paths?

Jul 14, 2010

Is it possible to scan all .aspx files in a web-site directory ? Suppose that , i've a home page like home.aspx, and many other pages.

How can i list all other pages with hyperlinks ?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved