我允许用户上传文件(doc、pdf、excel、txt),然后我传入 FileStream 进行读取然后写入,但打开它后我调用存储过程,以便我可以存储文件名、日期、上传用户,我将成为它的副本。我的问题是如何处理已在 FileStream 中传递的字符串文件名,而存储过程需要一个字符串文件名。
string docx = @"../../TestFiles/Test.docx";
try
{
FileStream fileStream = new FileStream(docx, FileMode.Open, FileAccess.Read);
docConverter.UpLoadFile(11, "Test.docx", "../../TestFiles/", 1, "../../Temp/", 89);
}
public void UpLoadFile(int studentId, string rawStoragePath, int uploadedByUserId, string storagePath, int assignmentElementsId)
{
Guid strGUID = Guid.NewGuid();
DateTime uploadDate = DateTime.UtcNow;
//calling stored procedure
stuSubSvc.UploadWork(studentId, strGUID, (need to pass file name), rawStoragePath, uploadDate, uploadedByUserId, storagePath, 0, assignmentElementsId);
}
帮助:
1 - 从 FileStream 中的文件中获取文件名
2 - 从 FileStream 中获取上传文件的路径