C#相当于C++;ostream::tellp用于软盘的大小限制 是否存在C++的StreamWriter流的C等价物:Telp?我正在把一些旧的C++代码移植到C语言,但是客户端仍然想要使用磁盘(读:旧设备),所以我需要找到一种方法来找到文件指针位置或者找到我已经写了多少磁盘。
以下是我迄今为止创建的方法:C#相当于C++;ostream::tellp用于软盘的大小限制 是否存在C++的StreamWriter流的C等价物:Telp?我正在把一些旧的C++代码移植到C语言,但是客户端仍然想要使用磁盘(读:旧设备),所以我需要找到一种方法来找到文件指针位置或者找到我已经写了多少磁盘。,c#,c++,streamwriter,ostream,C#,C++,Streamwriter,Ostream,以下是我迄今为止创建的方法: private bool isDisketteBoundary(ref StreamWriter swOutput, int nCurrentDisketteNo) { // Get current file pointer position // long filePosition = nOStream.tellp(); <-- C++ code long filePosition = 0; // <-- need
private bool isDisketteBoundary(ref StreamWriter swOutput, int nCurrentDisketteNo) {
// Get current file pointer position
// long filePosition = nOStream.tellp(); <-- C++ code
long filePosition = 0; // <-- needs to change to find file pointer position
// Valid?
if(filePosition != -1) {
// Is the new size over a boundary?
float numDiskettes = (float)((float)filePosition / (float)Constants.DisketteSize);
int disketteCount = Convert.ToInt32(Math.Ceiling(numDiskettes));
// Is the diskette count larger than the current index?
return (nCurrentDisketteNo < disketteCount) ? true : false;
}
else {
throw new Exception("Unable to get file pointer from StreamWriter");
}
}
private bool isdisketboundary(参考StreamWriter输出,int nCurrentDisketteNo){
//获取当前文件指针位置
//long filePosition=nOStream.tellp();我想您正在寻找
swOutput.BaseStream.Position
请参阅MSDN:。然后升级您的客户!;-)@Kos按照他们支付给我公司的金额,我认为这可能是个坏主意。:p真名是“软盘”=)@Calvin1602澄清一下,是3.5“不是5.25”或8“磁盘。:p