|
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace Common
{
public class FileOperation
{
[DllImport("FileStorage.dll", CharSet = CharSet.Unicode)]
public static extern Boolean AddDataToFile(string fileName, int typeOfData, string data, Int32 officeFile);
[DllImport("FileStorage.dll", CharSet = CharSet.Unicode)]
public static extern Boolean ReadDataFromFile(string fileName, int typeOfData, string data, UInt32 datasize, Int32 officeFile);
public Boolean AddData(string fileName, int typeOfData, string data)
{
//Adds the DocumentID in the file specified by fileName by calling
//AddDataToFile() which is exported by FileStorage.dll
Boolean retVal = false;
try
{
retVal = AddDataToFile(fileName, typeOfData, data, 1);
}
catch (Exception e)
{
}
finally
{
}
return retVal;
}
public Boolean ReadData(string fileName, int typeOfData, ref string data, UInt32 datasize)
{
//Reads the DocumentID in the file specified by fileName by calling
//ReadDataFromFile() which is exported by FileStorage.dll
Boolean retVal = false;
char[] temp = new char[260];
data = new string(temp);
try
{
retVal = ReadDataFromFile(fileName, typeOfData, data, 260, 1);
data = data.Replace('\0', ' ');
data = data.Trim();
}
catch (Exception e)
{
}
finally
{
}
return retVal;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.