1

I'm using Visual Studio 2015 to create a simple send mail program using EA Sendmail library. I try to send "D:\tmp\pic.jpg", after send success I would delete it by command remove("D:\\tmp\\pic.jpg") from #include<stdio.h>. But this file still there? What is my mistake?

1 Answers1

0

If that's Windows, three things can happen: 1. File still blocked by delayed operation of sending mail. 2. File was blocked by antivirus, while it may hook on ffile open activities, some AV just block file deletion\file movement. 3. Permissions issue. You're using non-standard folder, in root directory of disk..it inherited permission from the root directory, most likely. In your particular case you program runneth with insufficient (unelevated?)priveleges. 4. UTF-16 path issue. IS that real path you offer?

You're using remove() from standard library? that one based on POSIX "emulation" layer of Windows API that is lacking of Window-specific features.. you can't determine actual reasons and can't manipulate ACL\permissions and supports only Latin1 in path. Windows supports Unicode(UTF-16) on NTFS, but to use it, you need call functions from "native" API that accepts widechar strings (DeleteFileW). Windows API allows to get more error code states than POSIX. Also Windows got mechanisms to monitor\wait for file being if it is open by other operation, but that one available only to Elevated users, sadly, that's a kernel-level driver for taskmgr.

Swift - Friday Pie
  • 12,777
  • 2
  • 19
  • 42