|
Hi,
if you use "@" in front of a string every character inteh string is interpreted as a character and not as a control character. I.e. if you would do a "Console.WriteLine("Text1 \n\r Text2");" You would see
"Text1
Text2"
If you add a "@" in front of it so that it reads "Console.WriteLine(@"Text1 \n\r Text2");" You would see on your console window:
"Text1 \n\r Text2" because "\n\r" is not interpreted as a control character but as part of the string.
Here is a console app I wrote which should calrify things. I also show you another way to handle the filename and split it etc. by using a fileinfo object. Let me know if it helped you
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Version 1:");
//string[] files = System.IO.Directory.GetFiles(@"C:\temp");
string[] files = System.IO.Directory.GetFiles(@"\\192.168.1.4\temp");
foreach (string file in files)
{
Console.WriteLine(file);
}
Console.WriteLine("\n\rVersion 2:");
//string[] files = System.IO.Directory.GetFiles(@"C:\temp");
foreach (string file in files)
{
System.IO.FileInfo fileInfo = new System.IO.FileInfo(file);
Console.WriteLine(fileInfo.Name.Replace(fileInfo.Extension,String.Empty));
}
Console.WriteLine("Press Enter to exit...");
Console.Read();
}
}
Cheers
Peter
|
|
Expert:
|
PeterNZ
|
|
Date:
|
Aug 04, 2008
|
|
Time:
|
16:29
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
thanks very much for your response in detail. I now get an exception , I granted all permissions for my machine on the server for this particular folder(so that my machine has access to only this folder). I still have this problem. All suggestion would be greatly appreciated.
Thanks
Service cannot be started. System.UnauthorizedAccessException: Access to the path '\\Pdserver.tsiag.com\D$\devlibrary\images\tblItem338' is denied.
at MyfirstService.Service1.CopyImage() in C:\Documents and Settings\mduddebanda\My Documents\Visual Studio 2005\Projects\MyfirstService\MyfirstService\Service1.cs:line 110
at MyfirstService.Service1.OnStart(String[] args) in C:\Documents and Settings\mduddebanda\My Documents\Visual Studio 2005\Projects\MyfirstService\MyfirstService\Service1.cs:line 21
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
|
|
Expert:
|
mythilimythili
|
|
Date:
|
Aug 04, 2008
|
|
Time:
|
16:48
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
SOrry but I guess it is exactly what it says: "System.UnauthorizedAccessException: Access to the path '\\Pdserver.tsiag.com\D$\devlibrary\images\tblItem338' is denied. " You don't have access to the share. Can you try the IP address? Maybe the machine can't resolve your pdserver.tsiag.com? Under which user do you run your windows service? Does THIS user has access? If it is the local system user then the local system user needs access etc. Go to Administrative Tools, select your service and check under what user it runs!
Cheers
Peter
|
|
Expert:
|
PeterNZ
|
|
Date:
|
Aug 05, 2008
|
|
Time:
|
20:30
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
|