|
plz plz plz help me.
someone out there must know how to rename a file. thats is the only thing standing in the way of my class. i had a look on msdn but could not find what i was looking for.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Use System.IO.File.Move(originalName, newName);
After all, renaming is just moving it to the same folder with a different name.
|
|
|
|
|
Hi
Very easy indeed
From the static methods in the File class.
e.g.
File.Move(oldfilename, newfilename);
Moving has exactly the same effect as renaming except that you can rename to any path. But just to rename keep the paths the same.
Now go finish that class!
READ MSDN
|
|
|
|
|
In Visual C++ I could declare a static inside a function and no matter how many times this function was called it would only be called once.
ie.
public void foo1()
{
static int iCount = 0;
iCount++;
Console.WriteLine(iCount);
}
public void foo2()
{
while(true)
foo1();
}
This example should just continue to increment a value in the console because the initialization is only done once. How is this done in C#?
Thanks
|
|
|
|
|
IBF EHT KCAF wrote:
This example should just continue to increment a value in the console because the initialization is only done once. How is this done in C#?
It wouldn't be allowed. Static data would have to live in the class and not the methods. Also, Static anything has to have a full referrence to it. As an example:
class myOwn
{
static int myStaticStore = 0;
public int myMember(int StaticStore)
{
myOwn.myStaticStore=StaticStore;
return myOwn.myStaticStore;
}
}
Rocky Moore
|
|
|
|
|
Nope see in C++ this is totally allowed and it makes recurrsion really nice and easy. If I want to write a recursive function I want to be able to have variables inside the method that all the instances of that method can see.
I don't want to have 4 variables declared globally inside a class when only 1 method is using them. I want to declare them static inside a method so only 1 instance exists for all instances of that method.
If this isn't somehow possible in C# then this language has been totally *ucked for recurrsion (GOOD JOB Microsoft). You just took some real horsepower out of your own language.
|
|
|
|
|
bytewave wrote:
If this isn't somehow possible in C# then this language has been totally *ucked for recurrsion (GOOD JOB Microsoft). You just took some real horsepower out of your own language
It has the same functionality, only the scope of the variable is global to the class rather than per member. You will still only have _one_ varible, for all instances of the class just like in C++. The only time you would have a concern is if you planned to use a static variable of the same name in multiple methods as you could do in C++. Since they are up at the class level they would have to have different names.
Rocky Moore
|
|
|
|
|
Well...VB6 also has a "static" modifier that works the same way as C++...i don't know if VB.NET still has it...but it should be quite simple to implement in C# and yet Microsoft doesn't do it...another one is the With block which is in VB but not in C#...how irritating
|
|
|
|
|
Jonathan Tan wrote:
another one is the With block which is in VB but not in C#...how irritating
I agree with that. Would have been nice. I am just glad they put in "Using" to shorten all those referrence calls!
Rocky Moore
|
|
|
|
|
I don't really care either way, but the with statement is addressed here.
Andy Gaskell, MCSD MCDBA
|
|
|
|
|
Hi all,
Does anyone how to bring up the DataLink Properties Dialog for editing a connection string, like under the properties of a OleDbConnection?
Thanx in advance
READ MSDN
|
|
|
|
|
leppie wrote:
Does anyone how to bring up the DataLink Properties Dialog for editing a connection string, like under the properties of a OleDbConnection?
Not quite sure what you are asking. If you just want to modify the connection in a Wizard form, you can righ click on the connection you used in the Server Explorer and select Modify Connection.
Rocky Moore
|
|
|
|
|
Code:
MSDASC.DataLinks dl = new MSDASC.DataLinks();
dl.PromptNew();
You can find the whole information on msdn : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsqlmag2k/html/LinkAPI.asp
In C# project, you should add a com reference named : Microsoft OLE DB Service Component 1.0 Type Library
Good luck!
I'm amumu, and you?
|
|
|
|
|
Thx , exactly what I need, but how does one "cast" the returned object to an OleDbConnection? or a ConnectionString?
I presume I will need to implement a UITypeEditor as well as I need to show the property through a property grid.
READ MSDN
|
|
|
|
|
MSDASC.DataLinks dl = new MSDASC.DataLinks();
ADODB.Connection connection = dl.PromptNew() as ADODB.Connection;
if( null != connection )
MessageBox.Show( connection.ConnectionString );
You should add reference "Microsoft OLE DB Service Component 1.0 Type Library" and the "Microsoft ActiveX Data Objects 2.5 Library" to your project's reference.
I'm amumu, and you?
|
|
|
|
|
Hi and thx
qf0421 wrote:
MSDASC.DataLinks dl = new MSDASC.DataLinks();
ADODB.Connection connection = dl.PromptNew() as ADODB.Connection;
then as I'm using OleDb:
OldDbConnection conn = new OleDbConnection(connection.ConnectionString); ?
Cant test now but it should work. It just seems a bit over the top for such a "small" thing.
Another question, if you want to run this on another machine, do u need to register both dll's on the other PC or is the Interop.*.dll files ok for that?
READ MSDN
|
|
|
|
|
I think all dlls you refered are running at local machine, and two support remoting: web service and system.remoting, right? I'm not sure about it.
And also you can notice if you add a reference, vs.net will copy the file to your bin directory, does it means dll will be invoked local?
I'm amumu, and you?
|
|
|
|
|
How do i read one byte at a time from a remote file, i.e. a file from the web, then write each byte into a local file?
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
public static string RetrievePage(string url)
{
// Creates an HttpWebRequest with the specified URL.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
// Sends the HttpWebRequest and waits for the response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
// Gets the stream associated with the response.
Stream receiveStream = myHttpWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader( receiveStream, encode );
string retString = readStream.ReadToEnd();
myHttpWebResponse.Close();
return retString;
}
This function takes a URL as a string and the retrieves that URL. It shouldn't be difficult to modify this to make it work with binary (in fact I think it should work with no mods, but I can't be sure...).
Later,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
|
Manners kiddie, manners!
Big Bro is watching you
|
|
|
|
|
Is there anyone out there who knows how to bring Rich Text to a place other than in the windows controls? I need to be able to print RTF (rich text format) to paper, and I have no earthly idea how. Does anyone have any ideas at all? Thanks in advance
|
|
|
|
|
You can view some sample Printing Documentation here
You can also view some sample code from the SDK that uses a RichTextBox and prints the text from it.
Hope that helps!
--ChrisKo
|
|
|
|
|
I am not so fortunate as to have VS.NET yet so I make do with SharpDevelop. However most of you have VS.NET and release your apps as VS.NET projects.
I am trying to get a reference to Shell32 in my SD project. The reference is originally in the FTP client project in the C# section of CP.
The code has this:
private Shell32.Shell m_Shell;
Of course a compile error has appeared saying "What the hell is Shell32?". By examining the XML of the VS.NET project I can see that it references Shell32 as a GUID:
<Reference
Name = "Shell32"
Guid = "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}"
VersionMajor = "1"
VersionMinor = "0"
Lcid = "0"
WrapperTool = "tlbimp"
/>
How can I import this into SharpDevelop?
The Internet, whats that? Is it a car?
"There's a statistical theory that if you gave millions of monkeys typewriters and set them to work, they'd eventually come up with the complete works of Shakespere. Thanks to the Internet, we know this isn't true."
|
|
|
|
|
I need to do a comparison of two dynamic numbers - say 150 and 225. How can I figure out the percentage difference (in this case, 50%) between these two numbers in ASP.Net?
Thanks.
|
|
|
|