|
File.Move should not take any time if the move is to the same disk (i.e. a rename operation). Internally, it calls Windows' MoveFile function. There is no rename function in the Windows API itself.
It's possible that an implementation of the Windows file sharing MoveFile command isn't capable of doing this, but that would affect all file rename operations on that server.
|
|
|
|
|
Mike:
Thanks for your help!
Sheng
|
|
|
|
|
You actually have to use the Move method for this. In the source field, you give it the fully qualified path for the file you're renaming. In the destination parameter, you give it the same fully qualified path, but with the filename changed to the name you want it to be.
File.Move(@"C:\test\testfile.txt", @"C:\test\testfile2.dat")
If you give it fully qualified names for both parameters, but on different Shares or Drive Letters, then a Copy operation will take place, followed by a Delete of the original file.
File.Move(@"C:\test\testfile.txt", @"D:\test\testfile2.dat")
The same is true if you just give the filename as a destination parameter. This is because if only a filename is given, whatever the current directory is is assumed to be the destination path
Current directory is: C:\Program Files\MyApplication\
File.Move(@"D:\test\testfile.txt", @"testfile2.dat")
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave:
Your solution converges with Mike's. I think this is the correct way of renaming a file or directory. Thanks!
Sheng
|
|
|
|
|
Hello,
I'm trying to use sobe web methods in my windows service but I'm having a problem with the ones that need authentication.
The webservice has a method named "Authentication" but it returns always false. I set the cookiecontainer before calling this method, besides the cookiecontainer after the method is called it raises his count to 1. The result of the authentication is false. Which doesn't allow me to call other web methods that require authentication.
When i try exactly the same code with an aspx page, it works fine.
Does authentication has to always run in a browser?
How can i use in my windows service?
Code:
PalviewWS.Palview palview = new global::PWYDService.PalviewWS.Palview();
palview.CookieContainer = System.Net.CookieContainer();
bool result = palview.Authentication("xxx", "xxx");
Thanks in advance!
|
|
|
|
|
This is just a guess, but when you call the web service from your aspx page you are running under the context of your app pool. By default this is the aspnet user. Or you can set the identity of the app pool as well. Anyway, it is unlikely that your windows service is running under the aspnet user. I am guessing this is where your authentication problem is.
You can create a new local user, set the app pool to run as the user. Add that user to the IIS_WPG group so things will work properly in IIS. Then if you used that same user as the identity of your windows service, I am guessing you wouldn't have any more authentication problems.
I wrote an article recently that has steps at the bottom of it on how to set up a local user and set the app pool to be using that local user.
http://www.codeproject.com/useritems/SingleWebConfigFile.asp[^]
Hope that helps.
Ben
|
|
|
|
|
Hi,
I have a web app that needs to access a file on my server and apply a watermark of plain text including a timestamp, the file formats are likely to be tifs though that could change.
I have searched the forum and found one or two other posts on the issue but I'm new enough to c# and .net to not understand whats going on.
I know the locations of the files need to watermark, so am not working with a freshly uploaded file.
Can someone please at least point me in the right direction as I am wandering blind at the moment.
many thanks
mark
|
|
|
|
|
Basically you want to load the image, create a Graphics object on it (essentially a canvas) and then draw the text. Along the lines of:
using (Image imageToWatermark = Image.FromFile(filename))
{
using (Graphics gfx = Graphics.FromImage(imageToWatermark))
{
using (SolidBrush brush = new SolidBrush(Color.FromArgb(127, 255, 0, 0))
{
gfx.DrawString(watermarkText, brush, x, y);
}
}
imageToWaterpmark.Save(newFilename, ImageFormats.Png);
}
|
|
|
|
|
markymark82 wrote: apply a watermark of plain text including a timestamp, the file formats are likely to be tifs
markymark82 wrote: I'm new enough to c# and .net to not understand whats going on.
what's going on with what? Adding a watermark to an existing .tiff file has no direct connection with C# or the .NET platform. Do you know what is involved in adding a watermark to a .tiff file without regard to a specific programming language?
led mike
|
|
|
|
|
The language that I am using is C# on the .Net platform and no, I don't know what is involved, but I need to watermark drawings from my app, or at the least tell my app to instruct another external program to do the watermarking, preferabley from commandline.
I'm afraid i'm in at the deepend, but thats what comes of working for the MOD!
|
|
|
|
|
I think Ed.Poore gives you the simplest solution.
led mike
|
|
|
|
|
Hi, when you search CP for "watermark" you find many interesting articles
|
|
|
|
|
How can I make flash movies transparent using C# in .NET 2.0 win forms application ? Setting the WMMODE to transparent doesn't work. I know it's doable by using TransparencyKey on Form but it just doesn't work allways and I also need to make it work on 98's .
|
|
|
|
|
Windows 98 doesn't support Layered Windows, and hence doesn't support transparency. Layered Windows didn't show up until Windows 2000.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
And what about windows 2000 > . There is a flash player activeX control in .NET VS 2005 called Macromedia Flash Factory Object which can play flash. It has MWMODE setting , which when set to transparent doesn't do it's job. Is there any way to fix that ?
|
|
|
|
|
You'll have to ask Adobe about that. Since the Flash Player does it's own rendering, Transparency could work, but only inside the Flash window on your form. You won't be able to see through the form itself.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Check out this link, hope It helps you
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_14201
|
|
|
|
|
I'm not developing internet application, but windows forms application. That mwmode doesn't work as it suppose to...
|
|
|
|
|
|
|
RajeevKumarSharma wrote: i want to change any amount in words in c#.
as 1234 one thousand two hundread thirty four only.
please reply some one.
Gosh! I remember a similar homework exercise when I was at uni'
Start by writing down some numbers in numerical and word form. You will soon spot a repeating pattern.
1 to 20 don't repeat.
At 21 to 29 you have a pattern of "twenty" followed by n-20
At 31 to 39 you have a pattern of "thirty" followed by n-30
...
At 101 you have a pattern that has "one hundred and" followed by n-100
At 1001 you have a pattern that has "one thousand and" followed by n-1000
At 1101 you have a pattern that has "one thousand" followed by n-1000
NOTE 1: n-x means the pattern formed as if you subtraced n from x and used that pattern. e.g. 21 is twenty followed by 21-20 = 1 ==> twenty one
NOTE 2: These rules apply for Standard English. American English is slightly different.
|
|
|
|
|
Try this:
http://weblogs.asp.net/justin_rogers/archive/2004/06/09/151675.aspx
|
|
|
|
|
Colin Angus Mackay wrote: At 101 you have a pattern that has "one hundred and" followed by n-100
If I recall right from some math classes in school, you're not supposed to say 'and'. 101 becomes "one-hundred one". Maybe that's my non-standard American English.
|
|
|
|
|
Judah Himango wrote: If I recall right from some math classes in school, you're not supposed to say 'and'. 101 becomes "one-hundred one". Maybe that's my non-standard American English.
Yes, I was taught the exact reverse. "One hundred and one" is correct where I am. If you said "One hundred one" here without an accompanying American accent it would possibly be interpreted as two distinct numbers.
|
|
|
|
|
Colin Angus Mackay wrote: Yes, I was taught the exact reverse.
Funny. Although not quite as funny as the fanny differences. My wife watches "The Nanny" TV show, and the theme song for that show involves the Nanny getting thrown out on her fanny...now that I know "standard" English, I find that funny every time I hear the song.
|
|
|
|