473,568 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete and create file and folders

48 New Member
Dear friends,

I had host a server and now I have some problem.

I want to click on my web page and delete certain files in my computer. For instance, there is .txt file in my C Drive and I want to delete it, lets assume the file is at "C:\testing.txt ". So, since I host a server, I want to delete this file when I click some buttons at the web page. Is that possible?

Appreciate for any reply. Thank you.

Best Regards.
Mar 1 '07 #1
9 3031
Motoma
3,237 Recognized Expert Specialist
[PHP]<?php
exec("del C:\\somefile.tx t");
?>[/PHP]
Mar 1 '07 #2
kuzure
48 New Member
Dear Motoma,

I had tried the code, but it did not delete the file I chosen. By the way, after I tried the code, my Kaspersky detect a virus... ...It is coincidence? Or the code got problem? ^^haha. Dont get me wrong, I'm didnt mean that you send me virus, maybe the code will attract something, i guess... ... I believe this is a forum that helping us to solve problem. I had gain many knowledges here.

By the way, thanks for the reply, I will try the code again.

Best Regards.
Mar 2 '07 #3
vssp
268 Contributor
using unlink function to delete the files
Mar 2 '07 #4
r035198x
13,262 MVP
Yeah try
[PHP]<?php
unlink("C:/testing.txt");
?>
[/PHP]
Notice the forward slash
Mar 2 '07 #5
kuzure
48 New Member
Yeah try
[PHP]<?php
unlink("C:/testing.txt");
?>
[/PHP]
Notice the forward slash
Dear friend,

Thank you!!! It works!!!

Erm...then if I want to create a file, how can I do it? I mean I need to delete the file,for instance, "testing.tx t" because there are unwanted data store in there. So, after I delete it, I need to create a same file "testing.tx t" back to the same place, of course, with empty data.

By the way, can anyone tell me how to create a "browse box"? It called a browse box right? haha^^. Something like when I upload photo to friendster, there are a emtpy text box and beside it has a button "browse".

Thanks for the reply.

Best Regards.
Mar 3 '07 #6
r035198x
13,262 MVP
Dear friend,

Thank you!!! It works!!!

Erm...then if I want to create a file, how can I do it? I mean I need to delete the file,for instance, "testing.tx t" because there are unwanted data store in there. So, after I delete it, I need to create a same file "testing.tx t" back to the same place, of course, with empty data.

By the way, can anyone tell me how to create a "browse box"? It called a browse box right? haha^^. Something like when I upload photo to friendster, there are a emtpy text box and beside it has a button "browse".

Thanks for the reply.

Best Regards.

Try

[PHP]
<?php
$file = "C:/testing.txt";
if(!file_exists ($file)) {
$fout = fopen($file, "w");
}
?>
[/PHP]
For opening the file
Mar 3 '07 #7
kuzure
48 New Member
Dear r035198x,

I dont get the idea. What is this mean anyway "$fout = fopen($file, "w"); "?? Well, I just tried it, but the "testing.tx t" file still there, and the data I wrote in "If it works it will be blank later" still remain in the "testing.tx t".

Best Regards
Mar 3 '07 #8
r035198x
13,262 MVP
Dear r035198x,

I dont get the idea. What is this mean anyway "$fout = fopen($file, "w"); "?? Well, I just tried it, but the "testing.tx t" file still there, and the data I wrote in "If it works it will be blank later" still remain in the "testing.tx t".

Best Regards
I thought you said you have already deleted the file and now want to create a new one in which case that code will create the new file which will be blank.
Mar 3 '07 #9
kuzure
48 New Member
Dear r035198x,

Thanks for the reply. I know what happen already, I think I made a big mistake. haha^^.

Hrm, actually, instead of delete and replace a same file, is there any other way such like delete the data ONLY?

Wow, If I only read books to find out, it might take more time. haha^^ PHP really tough.

Best Regards.
Mar 4 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3808
by: andrea kampa | last post by:
Hi all, I'm a Win2000 professional user - sP 4. I can't delete some folders in e:\inetpub\wwwroot\...\. I've created them by FrontPage2000 SR1. I enter Windows as Administrator, then I should be able to create /delete all objects. On the contrary, each time I attempt to erase the assigned folder Windows warns me so: "Access is denied. The...
4
2233
by: Mark Reed | last post by:
Hi all, I have the following code which imports the contents of all files within a set folder which works excellently. Once it has imported from each file, it deletes the file. Is there a way that instead of deleting the file, I can move it to a log somewhere? Private Sub Command0_Click() 'procedure to import all files in a directory and...
3
1883
by: krock_112 | last post by:
I'm trying to set up a group of shared folders. Folder 1 Folder 2 Common Share I want all users that have access to folder 2 to be able to create new folders, add documents to the sub folders, pretty much do everything but delete. I have been unsuccesful so far. I either have to give everyone complete access which then gives them the...
9
8313
by: Paul | last post by:
I'm trying to make get my app to delete all the files in a specified folder and all the files within the folders of the specified folder. e.g. Folder 1 contains three files (File1, File2, File3) and two folders (Subfolder 1, Subfolder 2). .......I need to delete File1, File2, File3. Subfolder 1 contains FileA. .......Need to delete FileA....
10
2914
by: Dan | last post by:
Hi - I'm about a week into learning VB.NET, and I'm finding I can't delete any of the VB.NET directory structures that contain my test projects I've been trying to create. I've never seen this before... Whenever I try, it says something like "access is denied" and "make sure the disk is not write-protected and file is not currently in use". ...
2
21860
by: nospam | last post by:
I am writing this app in .net 2003 since all machines don't have 2.0 framework. I am trying to delete old profiles, but I am getting access denied or file in use errors. A lot of these files I am able to delete in Windows Explorer. The app is getting launched using the System account, so there is plenty of rights to delete the files. I...
4
2203
by: - HAL9000 | last post by:
When un-installing an application... Is it normal practice to write a special program that erases all the files and folders for all the users of an application that reads and writes to SpecialFolder.ApplicationData (C:\Documents and Settings\Username\Application Data) ? Or, is there some way to get the ms installer to do this for you? ...
1
2833
by: Sam | last post by:
This is probably the wrong group to post this in, but I'm not sure where it should go. If you have suggestions as to another group to post it let me know. In our Nant build file for our application. I want to first delete 2 folders if they exist. These folders then later get created. If the folders exist, I do not get errors, but if...
3
3379
by: Matt | last post by:
I have several folders on a server that contains files that go back 3-4 years. It was mentioned that keeping files that long is no longer needed. So my question is, is there a way to create a windows service in C# that can delete files in the folders that are older then 12 months? The server is structured something like this: DataLogs...
0
2934
by: wolfsbane | last post by:
Alright, here it is I am trying to write a win32 app in VB 2005 to clean up user's profiles. everything works correctly except for the Delete("directory", True) statement. I get a System.IO.DirectoryNotFoundException: Could not find a part of the path. Then it gives me a random file name from the UserProfile\Local Settings\Temporary Internet...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
932
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.