|
I am writing a code generator that reads in a text file containing source code. The file is my template and it contains {1}, {2}... {n} items in it. I read the file into a string and then I interpolate those values using String.Format(string format, params object[] args). It seems to work fine as long as I don't have any squiggly braces in it ({}) other than the ones that I want to use for formatting (e.g. the {1}, {2}, etc values). It appears that String.Format is choking on the other braces in the code template. I get the exception 'System.FormatException - Input string was not in the correct format'. Does anyone know why this is and how to fix it? Does this makes sense?
Thanks in advance.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Escaping braces is achieved by doubling them. Example : string s = Stirng.Format("my number {{is}} {0}",45);
Back to real work : D-26.
|
|
|
|
|
Gracias!!!
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
hi,
consider using the System.Text.Stringbuilder class ( method AppendFormat ). it is much faster with these kind of string operations.
franz
|
|
|
|
|
HELLO
SIR WE ARE DOING WORD PROGRAMMING USING C SHARP, HAVE PROBLEM IN USING PROPERTIES , AFTER ADDING MSWORD.OLB .
THERE ARE SOME INTERFACES AND CLASSES AS WELL , BUT HAVE PROBLEM IN USING PROPERTIES.
Asim
|
|
|
|
|
WHAT IS THE PROBLEM YOU ARE HAVING? TELL ME NOW. WE HAVE WAYS OF MAKING YOU TALK.
Pete
Insert Sig. Here!
|
|
|
|
|
thanks sir
we eventually have been able to use these properties.thanks for offering some favoure.
now the problem is how to display a picture, i.e we want to open a word document and want to get some picture if any and then to show it, now this is where the problem is we have opened word and got the picture from it but now problem is how to show it.
this is how we got the paragraph from word doc ,
Word.Range rngtext = aDoc.Application.ActiveDocument.Paragraphs.Item(2).Range;
MessageBox.Show(rngtext.Text);
now how to get show the picture?
Asim
|
|
|
|
|
"Capitalize words only to highlight an important point or to distinguish a title or heading. Capitalizing whole words that are not titles is generally termed as SHOUTING! "
the internet etiquette[^].
And, if you re-read your question, you'll probably figure out that we cannot answer anything about it.
Back to real work : D-26.
|
|
|
|
|
Simply press it: some light on the keyboard should turn off.
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|
Is your Caps-lock button broken? lol
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Hi, i'm trying to intercept window closing event of the AxSHDocVw.AxWebBrowser object (when a window.close() function is called in javascript) to do some specific task, but the form which contain this control is closed without any closing event raised.
What should i do?
|
|
|
|
|
Overriding Form.OnClosing is enough to get notified when a window is canned.
Back to real work : D-26.
|
|
|
|
|
I have a method on an OCX that takes void* parameter.
.Net create an interopt layer for this OCX and re-maps the void* to IntPtr
When I pass a IntPtr to this method. COM throws a parameter type mismatch exception.
This is because the IntPtr passed to method as a variant type of VT_INT and not VT_VOID.
How do I pass a IntPtr to this method with a variant type VT_VOID
|
|
|
|
|
void* is not a suitable type for the interop marshaller. I would suggest to either rewrite the IDL so it is something like IUnknown* (even if it's not an iunknown interface), or you could as well pass a SafeArray instead : in this case you have a marshall unmanagedtype enum [attribute] to play with to tell the marshaller what is the safearray made of.
Good luck!
Back to real work : D-26.
|
|
|
|
|
I have an xml file and xml class that its like this:
public class ModuleSettings
{
private string connectionString;
public ModuleSettings()
{ }
[XmlElement]
public string ConnectionString
{
get
{
return connectionString;
}
set
{
connectionString = value;
}
}
}
Then somewhere in my code I do this:
HttpContext context = HttpContext.Current;
ModuleSettings data = (ModuleSettings)context.Cache["Accounts_Settings"];
if (data == null)
{
XmlSerializer serializer = new XmlSerializer(typeof(ModuleSettings));
.
.
But last line caused unhandled error:
System.InvalidOperationException: Unable to generate a temporary class (result=1). error CS2001: Source file 'E:\WINDOWS\TEMP\ugkdowv3.0.cs' could not be found error CS2008: No inputs specified at System.Xml.Serialization.Compiler.Compile() at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings) at System.Xml.Serialization.XmlSerializer..ctor(Type type)
It was OK some day before when I test it but today came back to it and saw this happend.Any idea?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
I want to do some practice with XML.For example I have an XML file and I want to read/write each node or tag.I need some tutorial or article about it.Can someone suggest me to some points?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
The Quick Start[^] samples are pretty good for this IMO.
Paul Watson Bluegrass Cape Town, South Africa Ray Cassick wrote: Well I am not female, not gay and I am not Paul Watson
|
|
|
|
|
Thank you Paul.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
What's the best way to throttle the download speed on an httpwebrequest? It looks like it creates a seperate thread and does internal buffering on the download but I would like to have a max bandwidth limit imposed.
|
|
|
|
|
In a multitasking environment, it's not easy to create a perfect throttling system, but a simple one can be:
In a separate thread (because you don't want your program to "hang" waiting the download), after each "Read" call you do on the response stream, check the # of bytes received in the last second, let's call it nRead. If Speed >= nRead, sleep the rest of the second. If there's more to read, read min(Speed-nRead, you buffer size) bytes.
It's a bit confuse, but I think I made it clear...
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|
An Http Web Request/Response is internally managed by a System.Net.ServicePoint moniker which hides the underlying connection. This connection is buffered (hardcoded there, it's always 4KB), and there is no way to do direct throughput, which is probably why you see it slower than a standard WIN32 Wininet connection for instance.
The System.Net.Connection and System.Net.ConnectStream classes are not documented. That's however there where paquets are processed.
In addition, you cannot configure the underlying connections at the HttpWebRequest/HttpWebResponse API level.
Back to real work : D-26.
|
|
|
|
|
Good to know. Thanks for the prompt response. Is it possible however to use the Sockets classes to do software bandwidth restrictions?
|
|
|
|
|
The Socket class from .NET is a thin wrapper around Winsocks2. So that's plain hardcore TCPIP to fork with. At a point where even one could question the usefulness of doing socket programming with C#.
Back to real work : D-26.
|
|
|
|
|
I guess the main problem is that the webrequest/response method seems to hog all available bandwidth. Unlike when you open up several IE browsers at once on a slow link. They seem to be scheduled better.
But if I have downloads running from a webresponse, I'm not able to use IE at all with a dialup connection. All dns requests time out.
|
|
|
|
|
Hi there !
I want to embed the MS IE Control into my application ( as covered by some tutorials here )
However ih ave one special requirement.
Is it possible to get a BITMAP ( System.Drawing.Bitmap )
from this control ? I need that because i want to store it in a Texture for Managed DX9 .... any clues on this one ?
Of course it would also be great to do that even if the webbrowser was not visible on screen..
In C++ i did that already ( overridng WM_PRINT etc and copying the image data by hand )
But how to do this in C#/NET
Thanks
|
|
|
|