繁体   English   中英

如何给出文件路径而不是文件名 c++?

[英]How to give a file path instead of file name c++?

此代码部分来自一个简单的 md5 hash 生成器。但这里我只能给出一个文件名来生成 md5。

LPCWSTR NameOfTheFile = L"Test.txt"; //Name of the file that user is scanning

但我想在这里给出一个文件路径而不是文件名..有没有办法做到这一点。?

#include <iostream>
#include <windows.h> 
#include <fstream>
#include <string>

#define BUFSIZE 1024
#define MD5LEN  16


using namespace std;


DWORD main()
{

    MaximizeOutputWindow();

    DWORD cryptStatus = 0;

    BOOL hashResult = FALSE;

    BYTE fileSizeToHash[BUFSIZE];

    HCRYPTPROV cryptProv = 0;

    HCRYPTHASH hash = 0;

    HANDLE file = 0;

    DWORD hashNumbCount = 0;

    DWORD hashRead = 0;

    BYTE getHashValue[MD5LEN];

    CHAR numberConvert[] = "0123456789abcdef"; //hex decimal conversion

    LPCWSTR NameOfTheFile = L"Test.txt"; //Name of the file that user is scanning


    // Logic to check usage goes here.
    file = CreateFile(NameOfTheFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);

您可以将文件路径与CreateFile一起使用。 尝试类似NameOfTheFile = L"C:\\Text.txt";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM