on 02-23-2007 5:03 PM
Hi there,
what I want to do is have a text file that contains information particular to that machine.
My Add on will read this when loading up to access the information is this possible and how would i add it?
I have tried hard coding it to C:\config.txt but the add doesnt seem to like an external file?
Any ideas.
Hi Matthew,
You don't mention what development language you are using. As far as I know, if you are using .NET then you could use the FileStream object to read/write to a text file (see MSDN for full details at http://msdn2.microsoft.com/en-us/library/system.io.filestream(VS.80).aspx).
Perhaps you could post an example of the code you are using?
Kind Regards,
Owen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes i'm using VB.NET, all i need is to read in three lines form a text file like so. This works as i've run it through the debugger, however SAP doesnt seem to like it when i add my program as an add on.
Try
Dim objReader As IO.TextReader = System.IO.File.OpenText("D:\SAP\Config.txt") 'easier to put in with other program then not set path
config1 = objReader.ReadLine
config2 = objReader.ReadLine
config3 = objReader.ReadLine
objReader.Close()
Catch ex As Exception
SBO_Application.MessageBox("There is a problem with the configuration file: " + vbCrLf + ex.Message)
End Try
Also rather than have a hardcoded path i would rather have something like .\config to make it more flexible is this possible?
Matt
Hi!
There is no problem with B1 when reading files or... doing smth
Try StreamReader.
This is my C# example how to read lines and add elements, split by "\t" to the arrays.
StreamReader sr = new StreamReader(termTransDir + termTransferFileName);
while (sr.Peek() >= 0)
{
string itmLine = sr.ReadLine();
ArrayList arrItem = new ArrayList();
arrItem.AddRange(itmLine.Split('\t'));
arrTransItemCodes.Add(arrItem[0]);
arrTransItemNames.Add(arrItem[1]);
arrTransItemEANs.Add(arrItem[2]);
arrTransItemSerials.Add(arrItem[3]);
arrTransQty.Add(arrItem[4]);
}
sr.Close();
hth!
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.