temporary-files

How to create a temp file in java without the random number appended to the filename?

天大地大妈咪最大 提交于 2019-11-27 08:49:32
I need to create a temp file, so I tried this: String[] TempFiles = {"c1234c10","c1234c11","c1234c12","c1234c13"}; for (int i = 0; i <= 3; i++) { try { String tempFile = TempFiles[i]; File temp = File.createTempFile(tempFile, ".xls"); System.out.println("Temp file : " + temp.getAbsolutePath()); } catch (IOException e) { e.printStackTrace(); } } The output is something like this: Temp file : C:\Users\MD1000\AppData\Local\Temp\c1234c108415816200650069233.xls Temp file : C:\Users\MD1000\AppData\Local\Temp\c1234c113748833645638701089.xls Temp file : C:\Users\MD1000\AppData\Local\Temp

How to send image generated by PIL to browser?

陌路散爱 提交于 2019-11-27 06:33:29
I'm using flask for my application. I'd like to send an image (dynamically generated by PIL) to client without saving on disk. Any idea how to do this ? Adam Morris First, you can save the image to a tempfile and remove the local file (if you have one): from tempfile import NamedTemporaryFile from shutil import copyfileobj from os import remove tempFileObj = NamedTemporaryFile(mode='w+b',suffix='jpg') pilImage = open('/tmp/myfile.jpg','rb') copyfileobj(pilImage,tempFileObj) pilImage.close() remove('/tmp/myfile.jpg') tempFileObj.seek(0,0) Second, set the temp file to the response (as per this

PHP tmpfile() returns false

戏子无情 提交于 2019-11-27 06:19:48
问题 I've got an image upload script which was previously working. It's now broken, and I've traced the problem down to one line: $temp = tmpfile(); // $temp === false The tmpfile() function is returning false. I can't seem to figure out why. I'm having a hard time wading through Google on this one. The script it only broken on my local test environment, OSX 10.6.7, running MAMP 1.9.5. Fortunately the live site is working fine. 回答1: tmpfile() returns false if it is unable to create the temporary

Delete on close files

浪尽此生 提交于 2019-11-27 04:41:06
问题 Language used: C# Theory: I want to create a file with the flag FileOptions.DeleteOnClose in a temporary folder. The file is successfully created and I write dato onto it, the next step is to launch the application associated with the file Process.Start(...) and allow the user to inspect the document, finally I close my handle and as soon as other process close the handle to the temporary file, the file is deleted by operating system. My problem is that other processes cannot open the file,

How can I create a ramdisk in Python?

你。 提交于 2019-11-27 04:26:41
问题 I want to create a ramdisk in Python. I want to be able to do this in a cross-platform way, so it'll work on Windows XP-to-7, Mac, and Linux. I want to be able to read/write to the ramdisk like it's a normal drive, preferably with a drive letter/path. The reason I want this is to write tests for a script that creates a directory with a certain structure. I want to create the directory completely in the ramdisk so I'll be sure it would be completely deleted after the tests are over. I

ReflectedSchemas folder in the user's AppData folder (Visual Studio)

你说的曾经没有我的故事 提交于 2019-11-27 04:22:25
问题 Today I ran WinDirStat to check what is filling up my harddisk. I was surprised to see that this folder contains 4.6 GB (!): C:\Users\...\AppData\Roaming\Microsoft\VisualStudio\9.0\ReflectedSchemas What is the purpose of this folder and the files it contains? Is there a way to get rid of these files in a safe way? Thanks! 回答1: I've tried to empty the folder completely, and have no problems found since i've done. When launching a project in VS, a new schema was created. Edit: you can also move

iPhone storage in tmp directory

若如初见. 提交于 2019-11-27 04:05:24
问题 I have a question from this stackoverflow question about iPhone storage. Like I already tried to answer, we can cache data in tmp directory. But a comment says that the data can be deleted when OS whimp. I don't understand exactly the problem that the comment says. I want to ask if the process of OS deleting tmp directory is manually or automatically. In other words, if the system auto detect that our tmp directory has to be deleted. Another question is that if we can control, or be asked to

C# - How to Delete temporary internet files

末鹿安然 提交于 2019-11-27 03:34:22
问题 I want to clear the temporary Internet files folder completely. The location of the folder, e.g., C:\Users\Username\AppData\Local\Microsoft\Windows\Temporary Internet Files , depends on the version of Windows, so it has to be dynamic. 回答1: use this path: Environment.SpecialFolder.InternetCache string path = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) //for deleting files System.IO.DirectoryInfo di = new DirectoryInfo(path); foreach (FileInfo file in di.GetFiles()) {

Deleting tmp files

点点圈 提交于 2019-11-27 02:58:23
问题 I read this post on how to delete tmp files. The solution in that post is: do.call(file.remove, list(list.files("C:/Temp", full.names = TRUE))) The directory "C:/Temp" is presumably fine with windows machines. Since I'm on linux I wasn't sure what my tmp file dir was so I did this: tmp <- tempfile() Which returns: "/tmp/RtmpNS80no/file147c37e54e8e" So, I tried this: do.call(file.remove, list(list.files("tmp", full.names = TRUE))) This returns "logical(0)" so presumably did not work? How do I

How to prevent vim from creating (and leaving) temporary files?

只谈情不闲聊 提交于 2019-11-27 02:35:43
Why does vim create <filename>~ files? Is there a way to disable that? If it's for backup (or something), I use git for that. Also, these .<filename.with.path.hints>.swp files too. How do I tell vim not to create those, or at the least to cleanup after itself? EDIT whoops, duplicate: Why does Vim save files with a ~ extension? I adopted rogeriopvl's answer from there. verbatim copy: set nobackup "no backup files set nowritebackup "only in case you don't want a backup file while editing set noswapfile "no swap files I'd strongly recommend to keep working with swap files (in case Vim crashes).