doujiongqin0687 2012-11-19 08:44
浏览 57
已采纳

php调用的c#程序中的文件访问

This is the context: I've got to write a source for an intranet site which allows users to import a csv file into MySql database.

This import is very massive that's why I wrote a c# program.

This program creates some thread which reads some lines of my csv file.

These thread control, change type and insert my data into MySql database with sql like this:

insert into table1 (fields) values (dataline 1 ), (data line 25),...,(data line n);

This request exists for 9 tables.

This program can be used by everyone because the source code is dynamic : example to insert data I write a dictionary which contain my 9 tables with all fields, types and the CSV header of the import file (which contains some accent and symbol, I've to change it because I can't put them into fieldname in my database).

This dictionary can be create only with a file called MAP.csv

Example:

table   /   field     /    type  /   header

table 1  /  field1_table1 /string  / hêàder

table 1   / field2_table1/ int    /  header1

table 2   / field1_table2/ date   /  hêàder2

table 1  /  field3_table1/ string  / hêàder3

My c# program works very well when I execute the program.exe

But when I call it with php with exec("programpath.exe parameter1 parameter2",return,otherreturn) function this program can't work.

In fact when I try to access to externfile like config.xml , MAP.csv, otherfile.txt/csv/.. with my c# program. The execution stop and there is a windows error which says "program.exe stop its work" ( program.exe à cessé de fonctionner in French).

So I try to write my problem simply: when I try to access into a file with my c# program called by php, there is a window problem which stop the traitment.

EDIT : I found the solution, i just have to do a cd c:/path_program/ In fact when I start my website the current folder is not c:/ but the folder in wich symfony starts... Was just a beginner error. Thanks everybody for your help ! cia

  • 写回答

2条回答 默认 最新

  • drqefnd544707688 2012-11-19 14:28
    关注

    Check Edit post for the solution

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突