ecommerce web developer development freelance website designer India
I recently read somewhere, wish I remembered where, that "it's nearly impossible to create
any robust application without the use of Temp files."
I have to add to that: "IT managers wish all of the apps that created temp files would be coded
more professionally."
Sure, drive space is cheap, but they think it's annoying to go to a client's temp folder and see
hundreds of files with dates back to the Nixon administration, and with obscure file names not
using the traditional *.tmp extension that make you fear deleting them for what they *may* be all
about. Or worse, to find temp files that were not placed in the Temp folder, where they can be
easily deleted in one pass, but rather added to the app folder (and added and added and added).
In our apps, let's do the right thing. Use the computer's Temp folder to hold temporary files.
Finding that location is easy, just paste the following into a declarations section:

Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

And call it with a routine such as:

Public Property Get TempPathLocation() As String
Dim sBuffer As String * 255
If GetTempPath(255&, sBuffer) <> 0 Then
TempPathLocation = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
Else
TempPathLocation = ""
End If
End Property


This routine gets the computer's established Temp folder. If none has been established for the machine it returns "" which could be
interpreted as the current directory. If you want to be real nice to the IT guys and have them not shoot down your next project, set your
code to create a temp folder within the app.path if the routine returns the current directory (and nicely remind the company to create
Temp folders on their machines).

Now that you know where to put files, remember to remove them when you're done with them. If you allow multiple instances of your app
and dynamically create temp files using the traditional sFilename = "XYZ" & format(now, "hhnn") & ".tmp" hold a properly scoped
variable of the location and sFileName and Kill the file when you are through with it.
.Temp files

901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050

Express News India | Freelance ecommerce web development India