首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将文件保存在文件中

将文件保存在文件中
EN

Stack Overflow用户
提问于 2021-03-18 11:56:33
回答 1查看 202关注 0票数 1

我想将生成的文本文件保存在Acumatica页面的“file”部分,方法是单击“保存文件”。这是我当前生成文本文件的代码:

代码语言:javascript
复制
    string[] lines = { fileLine1, fileLine2, fileLine3 };
    File.WriteAllLines(path, lines);

这只是在我的机器上指定的路径中生成一个文本文件。

批量支付屏幕的屏幕截图

批付款屏幕

任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-18 15:30:04

我会尝试下面这样的东西,其中'message‘是一个字符串。

代码语言:javascript
复制
                using (MemoryStream stream = new MemoryStream())
                {
                    stream.Write(Encoding.UTF8.GetBytes(message), 0, message.Length);

                    string path = "MyFile.txt"; 
                    PX.SM.FileInfo info = new PX.SM.FileInfo(path, null, stream.ToArray());

                    //Attach file to Doc
                    info.Comment = "message generated on " + DateTime.Now.ToShortDateString();
                    UploadFileMaintenance upload = PXGraph.CreateInstance<UploadFileMaintenance>();

                    //Save file to acumatica
                    if (upload.SaveFile(info, FileExistsAction.CreateVersion))
                    {
                        //Create connection to the Batch
                        PXNoteAttribute.SetFileNotes(mysetup.connection.Cache, conn, info.UID.Value);
                        
                    }

                }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66690633

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档