I cannot get WEBMethods to write to my companies network drive. I can however access the network drive with a simple call in C# but cannot in Java. The network drive and the local drive Q: drive are shared to the same location. So I should be able to access the drive through the drive name and server or through the Q: drive.
I changed the drive name around so that no information could be seen that might tell someone drive names.
Question: Why can I access my Q: drive through C# (write and read) but not Java?
Code: (Java)
writer = new PrintWriter(new BufferedWriter(new FileWriter("\\\\A\\B\\S\\A B\\P\\T\TWM\\" + matcher.group(1) + ".txt")));
C# Code:
class Program
{
static void Main(string[] args)
{
//Read the file as one string.
string text1 = System.IO.File.ReadAllText(@"Q:\\S\ABCPS\T\TWM\T.txt");
//string text1 = System.IO.File.ReadAllText(@"\\E5\D\SYS\Tes\T.txt");
//string text1 = System.IO.File.ReadAllText(@"\\DS\ES\S\ABKS\T\TM\T.txt");
System.Console.WriteLine("Contents of WriteText.txt = {0}", text1);
string myLine = "Test line of code!!!!";
System.IO.File.WriteAllText(@"Q:SY\ACS\T\U\N.txt", myLine);
Console.WriteLine("Press any key to exit.");
System.Console.ReadKey();
}
}
Your question isn't related to the [webMethods] tag, so you're probably missing your target audience for this one.
However, you are missing one '\' in your Java program's path - "..T\TWM.." - so that may be where your issue lies.
BTW in general (excluding UNC paths) you can use forward slashes (/) in Java paths, and Java will automatically translate then when required for e.g. Windows. This does make pathnames in code easier to read, and portable to other operating systems (FWIW).