dbtjd0555navercom
dbtjd0555navercom

Reputation: 1

C# File ReadAllLine function disable after used dll(infinite wait)

The order of operation of my program is (Create file through dll call -> Read created file)

But it doesn't work.

After calling dll, the ReadAllLine function does not work and enters an infinite wait state. The cpu used is also 0.

How do I run a function and read a file?

[DllImport("Pcap_Parsing.dll", EntryPoint = "DEC_Parsing", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]

string FilePath = "file~~~/~~~/~~~.pcap"
string[] FileLines;

public static extern void DEC_Parsing(string fn);

Parsing(FilePath); //file create test.ini
FileLines = System.IO.File.ReadAllLines(~~~~path/test.ini); //When this function is executed, the cpu usage becomes 0 and it is in an infinite wait state. 

Upvotes: -1

Views: 56

Answers (1)

EL Khayar
EL Khayar

Reputation: 11

pcap files aren't a text file I think it is hard to use a method reads lines to string[]. try this without parsing it might work as all files saved on the devices are binaries.

    [DllImport("Pcap_Parsing.dll", EntryPoint = "DEC_Parsing", ExactSpelling = 
    true, CallingConvention = CallingConvention.Cdecl)]

    string FilePath = "file~~~/~~~/~~~.pcap"
    string[] FileLines;
    
    public static extern void DEC_Parsing(string fn)
    {
        var FileLines = System.IO.File.ReadAllBytes(filePath);

        string fileDecode = Encoding.ASCII.GetString(FileLines);
    } 

Upvotes: 0

Related Questions